title: How I will make a perfect time Reduction in golang?
body: <p>I'm making a cron job for the booking charge automatic. The admin set the automatic charge after 2 hour of booking completion then I Get all the booking completed before 2 hours from the current time and charge them automatic. But the problem arise in the end of the day is that <code>current_date= 10/10/2018 current_time= 1:00AM</code> and <code>automatic_charge_hours= 2</code> (hours) means it will get all the bookings which are completed 2 hours before the current_time and current_date. In 24hour format it will get all the bookings of the 23 hours(11:00PM of date 09/10/2018) of the previous date . But in my condition it will turn it into zero below is my condition:-</p>
  
  <pre><code>package main
  
  import (
    "fmt"
    "time"
    "strings"
  )
  
  func main() {
  timeZone, _ := time.LoadLocation("America/New_York")
  currDate := time.Now().In(timeZone).Format("2006-01-02 00:00:00 -0000")
  onlyDate := strings.Split(currDate, " ")
  hours, _ := 1, 0
  if hours-int(2) &lt; 0 {
      hours = 0
  } else {
      hours = hours - int(2)
  }
  fmt.Println(hours, onlyDate[0])
  }
  </code></pre>
  
  <p>playground link <a href="https://play.golang.org/p/w7LIoTp9xN0" rel="nofollow noreferrer">https://play.golang.org/p/w7LIoTp9xN0</a></p>
  
  <p>How will I change it. Any suggestions please.</p>