Documentation ¶
Index ¶
- Constants
- Variables
- func AddDay(t time.Time, day int) time.Time
- func AddHour(t time.Time, hour int) time.Time
- func AddMinutes(t time.Time, minutes int) time.Time
- func AddSeconds(t time.Time, seconds int) time.Time
- func Date(t time.Time, template string) string
- func DateFormat(t time.Time, template string) string
- func DayEnd(t time.Time) time.Time
- func DayStart(t time.Time) time.Time
- func Format(t time.Time) string
- func FormatBy(t time.Time, layout string) string
- func FormatByTpl(t time.Time, template string) string
- func FormatUnix(sec int64) string
- func FormatUnixBy(sec int64, layout string) string
- func FormatUnixByTpl(sec int64, template string) string
- func HourStart(t time.Time) time.Time
- func HowLongAgo(sec int64) string
- func NowAddDay(day int) time.Time
- func NowAddHour(hour int) time.Time
- func NowAddMinutes(minutes int) time.Time
- func NowAddSeconds(seconds int) time.Time
- func NowHourStart() time.Time
- func NowUnix() int64
- func SetLocalByName(tzName string) error
- func ToLayout(template string) string
- func TodayEnd() time.Time
- func TodayStart() time.Time
- type TimeX
- func (t *TimeX) AddDay(day int) *TimeX
- func (t *TimeX) AddHour(hours int) *TimeX
- func (t *TimeX) AddMinutes(minutes int) *TimeX
- func (t *TimeX) AddSeconds(seconds int) *TimeX
- func (t *TimeX) DateFormat(template string) string
- func (t *TimeX) Datetime() string
- func (t *TimeX) DayAfter(day int) *TimeX
- func (t *TimeX) DayAgo(day int) *TimeX
- func (t *TimeX) DayEnd() *TimeX
- func (t *TimeX) DayStart() *TimeX
- func (t TimeX) Diff(u time.Time) time.Duration
- func (t TimeX) DiffSec(u time.Time) int
- func (t *TimeX) Format(layout string) string
- func (t *TimeX) HourStart() *TimeX
- func (t TimeX) HowLongAgo(before time.Time) string
- func (t *TimeX) IsAfter(u time.Time) bool
- func (t *TimeX) IsBefore(u time.Time) bool
- func (t TimeX) SubUnix(u time.Time) int
- func (t *TimeX) Tomorrow() *TimeX
- func (t *TimeX) TplFormat(template string) string
- func (t *TimeX) Yesterday() *TimeX
Constants ¶
Variables ¶
var (
// DefaultLayout template for format time
DefaultLayout = "2006-01-02 15:04:05"
)
Functions ¶
func AddMinutes ¶
AddMinutes add some minutes time for given time
func AddSeconds ¶
AddSeconds add some seconds time for given time
func DateFormat ¶ added in v0.5.1
DateFormat format time by given date template. see ToLayout()
func FormatByTpl ¶ added in v0.5.1
FormatByTpl format time by given date template. see ToLayout()
func FormatUnixBy ¶
FormatUnixBy format time seconds use given layout
func FormatUnixByTpl ¶ added in v0.5.1
FormatUnixByTpl format time seconds use given date template. see ToLayout()
func HowLongAgo ¶ added in v0.5.1
HowLongAgo format given timestamp to string.
func NowAddMinutes ¶
NowAddMinutes add some minutes time from now
func NowAddSeconds ¶
NowAddSeconds add some seconds time from now
func SetLocalByName ¶
SetLocalByName set local by tz name. eg: UTC, PRC
Types ¶
type TimeX ¶
type TimeX struct { time.Time // Layout set the default date format layout. default use DefaultLayout Layout string }
TimeX struct
func FromString ¶ added in v0.5.1
FromString create from datetime string. see strutil.ToTime()
func (*TimeX) AddMinutes ¶
AddMinutes add some minutes time for the time
func (*TimeX) AddSeconds ¶
AddSeconds add some seconds time the time
func (*TimeX) DateFormat ¶ added in v0.5.1
DateFormat use input template format time to date. see ToLayout()
func (*TimeX) DayAfter ¶ added in v0.5.1
DayAfter get some day after time for the time. alias of TimeX.AddDay()
func (*TimeX) Format ¶ added in v0.5.1
Format returns a textual representation of the time value formatted according to the layout defined by the argument.
see time.Time.Format()
func (TimeX) HowLongAgo ¶ added in v0.5.1
HowLongAgo format diff time to string.