golang 的 rabbitmq 消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
422 B

  1. package tool
  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. }