You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""github.com/deatil/go-datebin/datebin"
)
funcmain() {
// now timedate:=datebin.
Now().
ToDatetimeString()
// output: 2024-01-06 12:06:12// Parse date and have no timezonedate2:=datebin.
Parse("2032-03-15 12:06:17").
ToDatetimeString(datebin.UTC)
// output: 2032-03-15 12:06:17// Parse date and have timezonedate2:=datebin.
ParseWithLayout("2032-03-15 12:06:17", datebin.DatetimeFormat, datebin.GMT).
ToDatetimeString()
// output: 2032-03-15 12:06:17// set time and format outputdate3:=datebin.
FromDatetime(2032, 3, 15, 12, 56, 5).
ToFormatString("Y/m/d H:i:s")
// output: 2032/03/15 12:56:05
}
Examples
// format timestampvardatetimeStringstring=datebin.FromTimestamp(1705329727, datebin.Shanghai).ToDatetimeString()
// output: 2024-01-15 22:42:07// format timestamp with timezonevardatetimeStringstring=datebin.FromTimestamp(1705329727).ToDatetimeString(datebin.Shanghai)
// output: 2024-01-15 22:42:07
// get now timestampvartimestampint64=datebin.Now().Timestamp()
// output: 1705329727
// get now timevartimestampint64=datebin.Now(datebin.Iran).ToRFC1123String()
// output: Sun, 21 Jan 2024 07:48:22 +0330
// get now stdtimevarstdTime time.Time=datebin.Now().ToStdTime()
// fmt.Sprintf("%s", stdTime) output: 2024-01-15 23:55:03.0770405 +0800 CST// get now stdtime with timezonevarstdTime time.Time=datebin.Now(datebin.UTC).ToStdTime()
// fmt.Sprintf("%s", stdTime) output: 2024-01-19 01:59:11.8134897 +0000 UTC
// format stdtimevardatetimeStringstring=datebin.FromStdTime(stdTime).ToDatetimeString()
// output: 2024-01-15 23:55:03