Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 nedēļām
1234567891011121314151617181920212223242526272829
  1. package zhios_order_relate_utils
  2. import "time"
  3. func Time2String(date time.Time, format string) string {
  4. if format == "" {
  5. format = "2006-01-02 15:04:05"
  6. }
  7. timeS := date.Format(format)
  8. if timeS == "0001-01-01 00:00:00" {
  9. return ""
  10. }
  11. return timeS
  12. }
  13. func String2Time(timeStr string) time.Time {
  14. toTime, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
  15. if err != nil {
  16. return time.Now()
  17. }
  18. return toTime
  19. }
  20. //GetDiffDays 获取两个时间相差的天数,0表同一天,正数表t1>t2,负数表t1<t2
  21. func GetDiffDays(t1, t2 time.Time) int {
  22. t1 = time.Date(t1.Year(), t1.Month(), t1.Day(), 0, 0, 0, 0, time.Local)
  23. t2 = time.Date(t2.Year(), t2.Month(), t2.Day(), 0, 0, 0, 0, time.Local)
  24. return int(t1.Sub(t2).Hours() / 24)
  25. }