Documentation
¶
Overview ¶
Package carbon is a simple, semantic and developer-friendly golang package for datetime
Index ¶
- Constants
- type Carbon
- func CreateFromDate(year int, month int, day int, timezone ...string) Carbon
- func CreateFromDateTime(year int, month int, day int, hour int, minute int, second int, ...) Carbon
- func CreateFromTime(hour int, minute int, second int, timezone ...string) Carbon
- func CreateFromTimestamp(timestamp int64, timezone ...string) Carbon
- func NewCarbon() Carbon
- func Now(timezone ...string) Carbon
- func Parse(value string, timezone ...string) Carbon
- func ParseByFormat(value string, format string, timezone ...string) Carbon
- func ParseByLayout(value string, layout string, timezone ...string) Carbon
- func SetLanguage(lang *Language) Carbon
- func SetLocale(locale string) Carbon
- func SetTimezone(name string) Carbon
- func Time2Carbon(tt time.Time) Carbon
- func Tomorrow(timezone ...string) Carbon
- func Yesterday(timezone ...string) Carbon
- func (c Carbon) AddCenturies(centuries int) Carbon
- func (c Carbon) AddCenturiesNoOverflow(centuries int) Carbon
- func (c Carbon) AddCentury() Carbon
- func (c Carbon) AddCenturyNoOverflow() Carbon
- func (c Carbon) AddDay() Carbon
- func (c Carbon) AddDays(days int) Carbon
- func (c Carbon) AddDecade() Carbon
- func (c Carbon) AddDecadeNoOverflow() Carbon
- func (c Carbon) AddDecades(decades int) Carbon
- func (c Carbon) AddDecadesNoOverflow(decades int) Carbon
- func (c Carbon) AddDuration(duration string) Carbon
- func (c Carbon) AddHour() Carbon
- func (c Carbon) AddHours(hours int) Carbon
- func (c Carbon) AddMinute() Carbon
- func (c Carbon) AddMinutes(minutes int) Carbon
- func (c Carbon) AddMonth() Carbon
- func (c Carbon) AddMonthNoOverflow() Carbon
- func (c Carbon) AddMonths(months int) Carbon
- func (c Carbon) AddMonthsNoOverflow(months int) Carbon
- func (c Carbon) AddQuarter() Carbon
- func (c Carbon) AddQuarterNoOverflow() Carbon
- func (c Carbon) AddQuarters(quarters int) Carbon
- func (c Carbon) AddQuartersNoOverflow(quarters int) Carbon
- func (c Carbon) AddSecond() Carbon
- func (c Carbon) AddSeconds(seconds int) Carbon
- func (c Carbon) AddWeek() Carbon
- func (c Carbon) AddWeeks(weeks int) Carbon
- func (c Carbon) AddYear() Carbon
- func (c Carbon) AddYearNoOverflow() Carbon
- func (c Carbon) AddYears(years int) Carbon
- func (c Carbon) AddYearsNoOverflow(years int) Carbon
- func (c Carbon) Age() int
- func (c Carbon) Between(start Carbon, end Carbon) bool
- func (c Carbon) BetweenIncludedBoth(start Carbon, end Carbon) bool
- func (c Carbon) BetweenIncludedEnd(start Carbon, end Carbon) bool
- func (c Carbon) BetweenIncludedStart(start Carbon, end Carbon) bool
- func (c Carbon) Carbon2Time() time.Time
- func (c Carbon) Century() int
- func (c Carbon) Compare(operator string, t Carbon) bool
- func (c Carbon) Constellation() string
- func (c Carbon) CreateFromDate(year int, month int, day int, timezone ...string) Carbon
- func (c Carbon) CreateFromDateTime(year int, month int, day int, hour int, minute int, second int, ...) Carbon
- func (c Carbon) CreateFromTime(hour int, minute int, second int, timezone ...string) Carbon
- func (c Carbon) CreateFromTimestamp(timestamp int64, timezone ...string) Carbon
- func (c Carbon) Day() int
- func (c Carbon) DayOfMonth() int
- func (c Carbon) DayOfWeek() int
- func (c Carbon) DayOfYear() int
- func (c Carbon) DaysInMonth() int
- func (c Carbon) DaysInYear() int
- func (c Carbon) Decade() int
- func (c Carbon) DiffForHumans(carbon ...Carbon) string
- func (c Carbon) DiffInDays(carbon ...Carbon) int64
- func (c Carbon) DiffInDaysWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInHours(carbon ...Carbon) int64
- func (c Carbon) DiffInHoursWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInMinutes(carbon ...Carbon) int64
- func (c Carbon) DiffInMinutesWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInMonths(carbon ...Carbon) int64
- func (c Carbon) DiffInMonthsWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInSeconds(carbon ...Carbon) int64
- func (c Carbon) DiffInSecondsWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInWeeks(carbon ...Carbon) int64
- func (c Carbon) DiffInWeeksWithAbs(carbon ...Carbon) int64
- func (c Carbon) DiffInYears(carbon ...Carbon) int64
- func (c Carbon) DiffInYearsWithAbs(carbon ...Carbon) int64
- func (c Carbon) EndOfCentury() Carbon
- func (c Carbon) EndOfDay() Carbon
- func (c Carbon) EndOfDecade() Carbon
- func (c Carbon) EndOfHour() Carbon
- func (c Carbon) EndOfMinute() Carbon
- func (c Carbon) EndOfMonth() Carbon
- func (c Carbon) EndOfQuarter() Carbon
- func (c Carbon) EndOfSeason() Carbon
- func (c Carbon) EndOfSecond() Carbon
- func (c Carbon) EndOfWeek(weekStartDay time.Weekday) Carbon
- func (c Carbon) EndOfYear() Carbon
- func (c Carbon) Eq(t Carbon) bool
- func (c Carbon) Format(format string, timezone ...string) string
- func (c Carbon) Gt(t Carbon) bool
- func (c Carbon) Gte(t Carbon) bool
- func (c Carbon) Hour() int
- func (c Carbon) IsApril() bool
- func (c Carbon) IsAquarius() bool
- func (c Carbon) IsAries() bool
- func (c Carbon) IsAugust() bool
- func (c Carbon) IsAutumn() bool
- func (c Carbon) IsCancer() bool
- func (c Carbon) IsCapricorn() bool
- func (c Carbon) IsDecember() bool
- func (c Carbon) IsFebruary() bool
- func (c Carbon) IsFriday() bool
- func (c Carbon) IsFuture() bool
- func (c Carbon) IsGemini() bool
- func (c Carbon) IsInvalid() bool
- func (c Carbon) IsJanuary() bool
- func (c Carbon) IsJuly() bool
- func (c Carbon) IsJune() bool
- func (c Carbon) IsLeapYear() bool
- func (c Carbon) IsLeo() bool
- func (c Carbon) IsLibra() bool
- func (c Carbon) IsLongYear() bool
- func (c Carbon) IsMarch() bool
- func (c Carbon) IsMay() bool
- func (c Carbon) IsMonday() bool
- func (c Carbon) IsNovember() bool
- func (c Carbon) IsNow() bool
- func (c Carbon) IsOctober() bool
- func (c Carbon) IsPast() bool
- func (c Carbon) IsPisces() bool
- func (c Carbon) IsSagittarius() bool
- func (c Carbon) IsSaturday() bool
- func (c Carbon) IsScorpio() bool
- func (c Carbon) IsSeptember() bool
- func (c Carbon) IsSpring() bool
- func (c Carbon) IsSummer() bool
- func (c Carbon) IsSunday() bool
- func (c Carbon) IsTaurus() bool
- func (c Carbon) IsThursday() bool
- func (c Carbon) IsToday() bool
- func (c Carbon) IsTomorrow() bool
- func (c Carbon) IsTuesday() bool
- func (c Carbon) IsVirgo() bool
- func (c Carbon) IsWednesday() bool
- func (c Carbon) IsWeekday() bool
- func (c Carbon) IsWeekend() bool
- func (c Carbon) IsWinter() bool
- func (c Carbon) IsYesterday() bool
- func (c Carbon) IsZero() bool
- func (c Carbon) Layout(layout string, timezone ...string) string
- func (c Carbon) Locale() string
- func (c Carbon) Location() string
- func (c Carbon) Lt(t Carbon) bool
- func (c Carbon) Lte(t Carbon) bool
- func (c Carbon) Lunar() (l lunar)
- func (c Carbon) Microsecond() int
- func (c Carbon) Millisecond() int
- func (c Carbon) Minute() int
- func (c Carbon) Month() int
- func (c Carbon) MonthOfYear() int
- func (c Carbon) Nanosecond() int
- func (c Carbon) Ne(t Carbon) bool
- func (c Carbon) Now(timezone ...string) Carbon
- func (c Carbon) Offset() int
- func (c Carbon) Parse(value string, timezone ...string) Carbon
- func (c Carbon) ParseByFormat(value string, format string, timezone ...string) Carbon
- func (c Carbon) ParseByLayout(value string, layout string, timezone ...string) Carbon
- func (c Carbon) Quarter() (quarter int)
- func (c *Carbon) Scan(v interface{}) error
- func (c Carbon) Season() string
- func (c Carbon) Second() int
- func (c Carbon) SetDay(day int) Carbon
- func (c Carbon) SetHour(hour int) Carbon
- func (c Carbon) SetLanguage(lang *Language) Carbon
- func (c Carbon) SetLocale(locale string) Carbon
- func (c Carbon) SetMicrosecond(microsecond int) Carbon
- func (c Carbon) SetMillisecond(millisecond int) Carbon
- func (c Carbon) SetMinute(minute int) Carbon
- func (c Carbon) SetMonth(month int) Carbon
- func (c Carbon) SetMonthNoOverflow(month int) Carbon
- func (c Carbon) SetNanosecond(nanosecond int) Carbon
- func (c Carbon) SetSecond(second int) Carbon
- func (c Carbon) SetTimezone(name string) Carbon
- func (c Carbon) SetYear(year int) Carbon
- func (c Carbon) SetYearNoOverflow(year int) Carbon
- func (c Carbon) StartOfCentury() Carbon
- func (c Carbon) StartOfDay() Carbon
- func (c Carbon) StartOfDecade() Carbon
- func (c Carbon) StartOfHour() Carbon
- func (c Carbon) StartOfMinute() Carbon
- func (c Carbon) StartOfMonth() Carbon
- func (c Carbon) StartOfQuarter() Carbon
- func (c Carbon) StartOfSeason() Carbon
- func (c Carbon) StartOfSecond() Carbon
- func (c Carbon) StartOfWeek(weekStartDay time.Weekday) Carbon
- func (c Carbon) StartOfYear() Carbon
- func (c Carbon) String() string
- func (c Carbon) SubCenturies(centuries int) Carbon
- func (c Carbon) SubCenturiesNoOverflow(centuries int) Carbon
- func (c Carbon) SubCentury() Carbon
- func (c Carbon) SubCenturyNoOverflow() Carbon
- func (c Carbon) SubDay() Carbon
- func (c Carbon) SubDays(days int) Carbon
- func (c Carbon) SubDecade() Carbon
- func (c Carbon) SubDecadeNoOverflow() Carbon
- func (c Carbon) SubDecades(decades int) Carbon
- func (c Carbon) SubDecadesNoOverflow(decades int) Carbon
- func (c Carbon) SubDuration(duration string) Carbon
- func (c Carbon) SubHour() Carbon
- func (c Carbon) SubHours(hours int) Carbon
- func (c Carbon) SubMinute() Carbon
- func (c Carbon) SubMinutes(minutes int) Carbon
- func (c Carbon) SubMonth() Carbon
- func (c Carbon) SubMonthNoOverflow() Carbon
- func (c Carbon) SubMonths(months int) Carbon
- func (c Carbon) SubMonthsNoOverflow(months int) Carbon
- func (c Carbon) SubQuarter() Carbon
- func (c Carbon) SubQuarterNoOverflow() Carbon
- func (c Carbon) SubQuarters(quarters int) Carbon
- func (c Carbon) SubQuartersNoOverflow(quarters int) Carbon
- func (c Carbon) SubSecond() Carbon
- func (c Carbon) SubSeconds(seconds int) Carbon
- func (c Carbon) SubWeek() Carbon
- func (c Carbon) SubWeeks(weeks int) Carbon
- func (c Carbon) SubYear() Carbon
- func (c Carbon) SubYearNoOverflow() Carbon
- func (c Carbon) SubYears(years int) Carbon
- func (c Carbon) SubYearsNoOverflow(years int) Carbon
- func (c Carbon) Timezone() string
- func (c Carbon) ToAnsicString(timezone ...string) string
- func (c Carbon) ToAtomString(timezone ...string) string
- func (c Carbon) ToCookieString(timezone ...string) string
- func (c Carbon) ToDateString(timezone ...string) string
- func (c Carbon) ToDateTimeString(timezone ...string) string
- func (c Carbon) ToDayDateTimeString(timezone ...string) string
- func (c Carbon) ToFormatString(format string, timezone ...string) string
- func (c Carbon) ToIso8601String(timezone ...string) string
- func (c Carbon) ToKitchenString(timezone ...string) string
- func (c Carbon) ToLayoutString(layout string, timezone ...string) string
- func (c Carbon) ToMonthString(timezone ...string) string
- func (c Carbon) ToRfc1036String(timezone ...string) string
- func (c Carbon) ToRfc1123String(timezone ...string) string
- func (c Carbon) ToRfc1123zString(timezone ...string) string
- func (c Carbon) ToRfc2822String(timezone ...string) string
- func (c Carbon) ToRfc3339String(timezone ...string) string
- func (c Carbon) ToRfc7231String(timezone ...string) string
- func (c Carbon) ToRfc822String(timezone ...string) string
- func (c Carbon) ToRfc822zString(timezone ...string) string
- func (c Carbon) ToRfc850String(timezone ...string) string
- func (c Carbon) ToRssString(timezone ...string) string
- func (c Carbon) ToRubyDateString(timezone ...string) string
- func (c Carbon) ToShortDateString(timezone ...string) string
- func (c Carbon) ToShortDateTimeString(timezone ...string) string
- func (c Carbon) ToShortMonthString(timezone ...string) string
- func (c Carbon) ToShortTimeString(timezone ...string) string
- func (c Carbon) ToShortWeekString(timezone ...string) string
- func (c Carbon) ToString(timezone ...string) string
- func (c Carbon) ToTimeString(timezone ...string) string
- func (c Carbon) ToTimestamp() int64
- func (c Carbon) ToTimestampWithMicrosecond() int64
- func (c Carbon) ToTimestampWithMillisecond() int64
- func (c Carbon) ToTimestampWithNanosecond() int64
- func (c Carbon) ToTimestampWithSecond() int64
- func (c Carbon) ToUnixDateString(timezone ...string) string
- func (c Carbon) ToW3cString(timezone ...string) string
- func (c Carbon) ToWeekString(timezone ...string) string
- func (c Carbon) Tomorrow(timezone ...string) Carbon
- func (c Carbon) Value() (driver.Value, error)
- func (c Carbon) Week() int
- func (c Carbon) WeekOfMonth() int
- func (c Carbon) WeekOfYear() int
- func (c Carbon) Year() int
- func (c Carbon) Yesterday(timezone ...string) Carbon
- type Language
- type ToDateString
- type ToDateTimeString
- type ToTimeString
- type ToTimestamp
- type ToTimestampWithMicrosecond
- type ToTimestampWithMillisecond
- type ToTimestampWithNanosecond
- type ToTimestampWithSecond
Constants ¶
const ( Local = "Local" CET = "CET" EET = "EET" EST = "EST" GMT = "GMT" UTC = "UTC" UCT = "UCT" MST = "MST" Cuba = "Cuba" // 古巴 Egypt = "Egypt" // 埃及 Eire = "Eire" // 爱尔兰 Greenwich = "Greenwich" // 格林尼治 Iceland = "Iceland" // 冰岛 Iran = "Iran" // 伊朗 Israel = "Israel" // 以色列 Jamaica = "Jamaica" // 牙买加 Japan = "Japan" // 日本 Libya = "Libya" // 利比亚 Poland = "Poland" // 波兰 Portugal = "Portugal" // 葡萄牙 PRC = "PRC" // 中国 Singapore = "Singapore" // 新加坡 Turkey = "Turkey" // 土耳其 Shanghai = "Asia/Shanghai" // 上海 Chongqing = "Asia/Chongqing" // 重庆 Harbin = "Asia/Harbin" // 哈尔滨 HongKong = "Asia/Hong_Kong" // 香港 Macao = "Asia/Macao" // 澳门 Taipei = "Asia/Taipei" // 台北 Tokyo = "Asia/Tokyo" // 东京 Saigon = "Asia/Saigon" // 西贡 Seoul = "Asia/Seoul" // 首尔 Bangkok = "Asia/Bangkok" // 曼谷 Dubai = "Asia/Dubai" // 迪拜 NewYork = "America/New_York" // 纽约 LosAngeles = "America/Los_Angeles" // 洛杉矶 Chicago = "America/Chicago" // 芝加哥 Moscow = "Europe/Moscow" // 莫斯科 London = "Europe/London" // 伦敦 Berlin = "Europe/Berlin" // 柏林 Paris = "Europe/Paris" // 巴黎 Rome = "Europe/Rome" // 罗马 )
时区常量
const ( January = "January" // 一月 February = "February" // 二月 March = "March" // 三月 April = "April" // 四月 May = "May" // 五月 June = "June" // 六月 July = "July" // 七月 August = "August" // 八月 September = "September" // 九月 October = "October" // 十月 November = "November" // 十一月 December = "December" // 十二月 )
月份常量
const ( Monday = "Monday" // 周一 Tuesday = "Tuesday" // 周二 Wednesday = "Wednesday" // 周三 Thursday = "Thursday" // 周四 Friday = "Friday" // 周五 Saturday = "Saturday" // 周六 Sunday = "Sunday" // 周日 )
星期常量
const ( YearsPerMillennium = 1000 // 每千年1000年 YearsPerCentury = 100 // 每世纪100年 YearsPerDecade = 10 // 每十年10年 QuartersPerYear = 4 // 每年4季度 MonthsPerYear = 12 // 每年12月 MonthsPerQuarter = 3 // 每季度3月 WeeksPerNormalYear = 52 // 每常规年52周 WeeksPerMonth = 4 // 每月4周 DaysPerLeapYear = 366 // 每闰年366天 DaysPerNormalYear = 365 // 每常规年365天 DaysPerWeek = 7 // 每周7天 HoursPerWeek = 168 // 每周168小时 HoursPerDay = 24 // 每天24小时 MinutesPerDay = 1440 // 每天1440分钟 MinutesPerHour = 60 // 每小时60分钟 SecondsPerWeek = 604800 // 每周604800秒 SecondsPerDay = 86400 // 每天86400秒 SecondsPerHour = 3600 // 每小时3600秒 SecondsPerMinute = 60 // 每分钟60秒 MillisecondsPerSecond = 1000 // 每秒1000毫秒 MicrosecondsPerMillisecond = 1000 // 每毫秒1000微秒 MicrosecondsPerSecond = 1000000 // 每秒1000000微秒 )
数字常量
const ( AnsicFormat = time.ANSIC UnixDateFormat = time.UnixDate RubyDateFormat = time.RubyDate RFC822Format = time.RFC822 RFC822ZFormat = time.RFC822Z RFC850Format = time.RFC850 RFC1123Format = time.RFC1123 RFC1123ZFormat = time.RFC1123Z RssFormat = time.RFC1123Z RFC2822Format = time.RFC1123Z RFC3339Format = time.RFC3339 KitchenFormat = time.Kitchen Iso8601Format = "2006-01-02T15:04:05-07:00" CookieFormat = "Monday, 02-Jan-2006 15:04:05 MST" RFC1036Format = "Mon, 02 Jan 06 15:04:05 -0700" RFC7231Format = "Mon, 02 Jan 2006 15:04:05 GMT" DayDateTimeFormat = "Mon, Jan 2, 2006 3:04 PM" DateTimeFormat = "2006-01-02 15:04:05" DateFormat = "2006-01-02" TimeFormat = "15:04:05" ShortDateTimeFormat = "20060102150405" ShortDateFormat = "20060102" ShortTimeFormat = "150405" )
时间格式化常量
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Carbon ¶
Carbon define Carbon structure 定义 Carbon 结构体
func CreateFromDate ¶ added in v1.2.0
CreateFromDate create a Carbon instance from a given date 从给定的年月日创建 Carbon 实例
func CreateFromDateTime ¶ added in v1.2.0
func CreateFromDateTime(year int, month int, day int, hour int, minute int, second int, timezone ...string) Carbon
CreateFromDateTime create a Carbon instance from a given date and time 从给定的年月日时分秒创建 Carbon 实例
func CreateFromTime ¶ added in v1.2.0
CreateFromTime create a Carbon instance from a given time 从给定的时分秒创建 Carbon 实例
func CreateFromTimestamp ¶ added in v1.2.0
CreateFromTimestamp create a Carbon instance from a given timestamp 从给定的时间戳创建 Carbon 实例
func NewCarbon ¶ added in v1.3.9
func NewCarbon() Carbon
NewCarbon return a new Carbon instance 初始化 Carbon 结构体
func Parse ¶ added in v1.2.0
Parse parse a standard string as a Carbon instance 将标准时间字符串解析成 Carbon 实例
func ParseByFormat ¶ added in v1.2.0
ParseByFormat parse a string as a Carbon instance by format 通过布局字符将字符串解析成 carbon 实例
func ParseByLayout ¶ added in v1.3.0
ParseByLayout parse a string as a Carbon instance by layout 将布局时间字符串解析成 Carbon 实例
func SetLanguage ¶ added in v1.3.4
SetLanguage set language 设置语言对象
func SetTimezone ¶ added in v1.2.2
SetTimezone set timezone 设置时区
func Time2Carbon ¶ added in v1.3.0
Time2Carbon convert time.Time into Carbon 将 time.Time 转换成 Carbon
func (Carbon) AddCenturies ¶ added in v1.2.6
AddCenturies add some centuries N个世纪后
func (Carbon) AddCenturiesNoOverflow ¶ added in v1.3.0
AddCenturiesNoOverflow add some centuries without overflowing month N个世纪后(月份不溢出)
func (Carbon) AddCentury ¶ added in v1.2.6
AddCentury add one century 1个世纪后
func (Carbon) AddCenturyNoOverflow ¶ added in v1.3.0
AddCenturyNoOverflow add one century without overflowing month 1个世纪后(月份不溢出)
func (Carbon) AddDecadeNoOverflow ¶ added in v1.5.2
AddDecadeNoOverflow add one decade without overflowing month 1个年代后(月份不溢出)
func (Carbon) AddDecades ¶ added in v1.5.2
AddDecades add some decades N个年代后
func (Carbon) AddDecadesNoOverflow ¶ added in v1.5.2
AddDecadesNoOverflow add some decades without overflowing month N个年代后(月份不溢出)
func (Carbon) AddDuration ¶ added in v1.2.4
AddDuration add one duration 按照持续时长字符串增加时间,支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合
func (Carbon) AddMinutes ¶
AddMinutes add some minutes N分钟后
func (Carbon) AddMonthNoOverflow ¶ added in v1.3.0
AddMonthNoOverflow add one month without overflowing month 1个月后(月份不溢出)
func (Carbon) AddMonthsNoOverflow ¶ added in v1.3.0
AddMonthsNoOverflow add some months without overflowing month N个月后(月份不溢出)
func (Carbon) AddQuarter ¶ added in v1.2.3
AddQuarter add one quarter 1个季度后
func (Carbon) AddQuarterNoOverflow ¶ added in v1.3.0
AddQuarterNoOverflow add one quarter without overflowing month 1个季度后(月份不溢出)
func (Carbon) AddQuarters ¶ added in v1.2.3
AddQuarters add some quarters N个季度后
func (Carbon) AddQuartersNoOverflow ¶ added in v1.3.0
AddQuartersNoOverflow add quarters without overflowing month N个季度后(月份不溢出)
func (Carbon) AddSeconds ¶
AddSeconds add some seconds N秒钟后
func (Carbon) AddYearNoOverflow ¶ added in v1.3.0
AddYearNoOverflow add one year without overflowing month 1年后(月份不溢出)
func (Carbon) AddYearsNoOverflow ¶ added in v1.3.0
AddYearsNoOverflow add some years without overflowing month N年后(月份不溢出)
func (Carbon) Between ¶ added in v1.2.4
Between whether between two Carbon instances, excluded the start and end Carbon instance 是否在两个时间之间(不包括这两个时间)
func (Carbon) BetweenIncludedBoth ¶ added in v1.2.4
BetweenIncludedBoth whether between two Carbon instances, included the start and end Carbon instance 是否在两个时间之间(包括这两个时间)
func (Carbon) BetweenIncludedEnd ¶ added in v1.4.5
BetweenIncludedEnd whether between two Carbon instances, included the end Carbon instance 是否在两个时间之间(包括结束时间)
func (Carbon) BetweenIncludedStart ¶ added in v1.4.5
BetweenIncludedStart whether between two Carbon instances, included the start Carbon instance 是否在两个时间之间(包括开始时间)
func (Carbon) Carbon2Time ¶ added in v1.3.0
Carbon2Time convert Carbon into time.Time 将 Carbon 转换成 time.Time
func (Carbon) Constellation ¶ added in v1.3.4
Constellation get constellation name, i18n is supported 获取星座,支持i18n
func (Carbon) CreateFromDate ¶
CreateFromDate create a Carbon instance from a given date 从给定的年月日创建 Carbon 实例
func (Carbon) CreateFromDateTime ¶
func (c Carbon) CreateFromDateTime(year int, month int, day int, hour int, minute int, second int, timezone ...string) Carbon
CreateFromDateTime create a Carbon instance from a given date and time 从给定的年月日时分秒创建 Carbon 实例
func (Carbon) CreateFromTime ¶
CreateFromTime create a Carbon instance from a given time 从给定的时分秒创建 Carbon 实例
func (Carbon) CreateFromTimestamp ¶
CreateFromTimestamp create a Carbon instance from a given timestamp, second, millisecond, microsecond and nanosecond are supported 从给定的时间戳创建 Carbon 实例,支持秒、毫秒、微秒和纳秒
func (Carbon) DayOfMonth ¶ added in v1.2.0
DayOfMonth get day of month 获取本月的第几天
func (Carbon) DaysInMonth ¶ added in v1.2.0
DaysInMonth get days in month 获取本月的总天数
func (Carbon) DaysInYear ¶ added in v1.2.0
DaysInYear get days in year 获取本年的总天数
func (Carbon) DiffForHumans ¶ added in v1.3.1
DiffForHumans get the difference in a human readable format, i18n is supported 获取对人类友好的可读格式时间差,支持i18n
func (Carbon) DiffInDays ¶ added in v1.2.2
DiffInDays get the difference in days 相差多少天
func (Carbon) DiffInDaysWithAbs ¶ added in v1.2.4
DiffInDaysWithAbs get the difference in days with absolute value 相差多少天(绝对值)
func (Carbon) DiffInHours ¶ added in v1.2.2
DiffInHours get the difference in hours 相差多少小时
func (Carbon) DiffInHoursWithAbs ¶ added in v1.2.4
DiffInHoursWithAbs get the difference in hours with absolute value 相差多少小时(绝对值)
func (Carbon) DiffInMinutes ¶ added in v1.2.2
DiffInMinutes get the difference in minutes 相差多少分钟
func (Carbon) DiffInMinutesWithAbs ¶ added in v1.2.4
DiffInMinutesWithAbs get the difference in minutes with absolute value 相差多少分钟(绝对值)
func (Carbon) DiffInMonths ¶ added in v1.3.1
DiffInMonths get the difference in months 相差多少月
func (Carbon) DiffInMonthsWithAbs ¶ added in v1.3.1
DiffInMonthsWithAbs get the difference in months with absolute value 相差多少月(绝对值)
func (Carbon) DiffInSeconds ¶ added in v1.2.2
DiffInSeconds get the difference in seconds 相差多少秒
func (Carbon) DiffInSecondsWithAbs ¶ added in v1.2.4
DiffInSecondsWithAbs get the difference in seconds with absolute value 相差多少秒(绝对值)
func (Carbon) DiffInWeeks ¶ added in v1.2.2
DiffInWeeks get the difference in weeks 相差多少周
func (Carbon) DiffInWeeksWithAbs ¶ added in v1.2.4
DiffInWeeksWithAbs get the difference in weeks with absolute value 相差多少周(绝对值)
func (Carbon) DiffInYears ¶ added in v1.3.1
DiffInYears get the difference in years 相差多少年
func (Carbon) DiffInYearsWithAbs ¶ added in v1.3.1
DiffInYearsWithAbs get the difference in years with absolute value 相差多少年(绝对值)
func (Carbon) EndOfCentury ¶ added in v1.4.0
EndOfCentury return a Carbon instance for end of the century 本世纪结束时间
func (Carbon) EndOfDecade ¶ added in v1.4.2
EndOfDecade return a Carbon instance for end of the decade 本年代结束时间
func (Carbon) EndOfHour ¶ added in v1.2.1
EndOfHour return a Carbon instance for end of the hour 小时结束时间
func (Carbon) EndOfMinute ¶ added in v1.2.1
EndOfMinute return a Carbon instance for end of the minute 分钟结束时间
func (Carbon) EndOfMonth ¶
EndOfMonth return a Carbon instance for end of the month 本月结束时间
func (Carbon) EndOfQuarter ¶ added in v1.4.0
EndOfQuarter return a Carbon instance for end of the quarter 本季度结束时间
func (Carbon) EndOfSeason ¶ added in v1.4.2
EndOfSeason return a Carbon instance for end of the season 本季节结束时间
func (Carbon) EndOfSecond ¶ added in v1.3.4
EndOfSecond return a Carbon instance for end of the second 秒结束时间
func (Carbon) EndOfWeek ¶ added in v1.2.1
EndOfWeek return a Carbon instance for end of the week 本周结束时间
func (Carbon) Format ¶
Format Output a string by format, it is short for ToFormatString 输出指定格式的时间字符串, 是 ToFormatString 的简写
func (Carbon) IsAquarius ¶ added in v1.3.4
IsAquarius whether is Aquarius 是否是水瓶座
func (Carbon) IsCapricorn ¶ added in v1.3.4
IsCapricorn whether is Capricorn 是否是摩羯座
func (Carbon) IsLeapYear ¶
IsLeapYear whether is a leap year 是否是闰年
func (Carbon) IsLongYear ¶ added in v1.2.2
IsLongYear whether is a long year, see https://en.wikipedia.org/wiki/ISO_8601#Week_dates 是否是长年
func (Carbon) IsSagittarius ¶ added in v1.3.4
IsSagittarius whether is Sagittarius 是否是射手座
func (Carbon) IsSeptember ¶
IsSeptember whether is September 是否是九月
func (Carbon) IsWednesday ¶
IsWednesday whether is Wednesday 是否是周三
func (Carbon) IsYesterday ¶
IsYesterday whether is yesterday 是否是昨天
func (Carbon) Layout ¶ added in v1.4.4
Layout Output a string by layout, it is short for ToLayoutString 输出指定布局的时间字符串, 是 ToLayoutString 的简写
func (Carbon) Lunar ¶ added in v1.4.1
func (c Carbon) Lunar() (l lunar)
Lunar convert the gregorian calendar into the lunar calendar 将公历转为农历
func (Carbon) Microsecond ¶ added in v1.2.3
Microsecond get current microsecond 获取当前微秒数,6位数字
func (Carbon) Millisecond ¶ added in v1.2.3
Millisecond get current millisecond 获取当前毫秒数,3位数字
func (Carbon) MonthOfYear ¶ added in v1.2.0
MonthOfYear get month of year 获取本年的第几月
func (Carbon) Nanosecond ¶ added in v1.2.3
Nanosecond get current nanosecond 获取当前纳秒数,9位数字
func (Carbon) Offset ¶ added in v1.4.4
Offset get offset seconds from the UTC timezone 获取距离UTC时区的偏移量,单位秒
func (Carbon) ParseByFormat ¶
ParseByFormat parse a string as a Carbon instance by format 通过格式化字符将字符串解析成 carbon 实例
func (Carbon) ParseByLayout ¶ added in v1.3.0
ParseByLayout parse a string as a Carbon instance by layout 通过布局字符将字符串解析成 carbon 实例
func (*Carbon) Scan ¶
Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
func (Carbon) Season ¶ added in v1.4.2
Season get season name according to the meteorological division method, i18n is supported 获取当前季节(以气象划分),支持i18n
func (Carbon) SetLanguage ¶ added in v1.3.4
SetLanguage set language 设置语言对象
func (Carbon) SetMicrosecond ¶ added in v1.3.7
SetMicrosecond set microsecond 设置微秒
func (Carbon) SetMillisecond ¶ added in v1.3.7
SetMillisecond set millisecond 设置毫秒
func (Carbon) SetMonthNoOverflow ¶ added in v1.5.2
SetMonthNoOverflow set month without overflowing month 设置月(月份不溢出)
func (Carbon) SetNanosecond ¶ added in v1.3.7
SetNanosecond set nanosecond 设置纳秒
func (Carbon) SetTimezone ¶ added in v1.2.2
SetTimezone set timezone 设置时区
func (Carbon) SetYearNoOverflow ¶ added in v1.5.2
SetYearNoOverflow set year without overflowing month 设置年(月份不溢出)
func (Carbon) StartOfCentury ¶ added in v1.4.0
StartOfCentury return a Carbon instance for start of the century 本世纪开始时间
func (Carbon) StartOfDay ¶
StartOfDay return a Carbon instance for start of the day 本日开始时间
func (Carbon) StartOfDecade ¶ added in v1.4.2
StartOfDecade return a Carbon instance for start of the decade 本年代开始时间
func (Carbon) StartOfHour ¶ added in v1.2.2
StartOfHour return a Carbon instance for start of the hour 小时开始时间
func (Carbon) StartOfMinute ¶ added in v1.2.2
StartOfMinute return a Carbon instance for start of the minute 分钟开始时间
func (Carbon) StartOfMonth ¶
StartOfMonth return a Carbon instance for start of the month 本月开始时间
func (Carbon) StartOfQuarter ¶ added in v1.4.0
StartOfQuarter return a Carbon instance for start of the quarter 本季度开始时间
func (Carbon) StartOfSeason ¶ added in v1.4.2
StartOfSeason return a Carbon instance for start of the season 本季节开始时间
func (Carbon) StartOfSecond ¶ added in v1.3.4
StartOfSecond return a Carbon instance for start of the second 秒开始时间
func (Carbon) StartOfWeek ¶ added in v1.2.2
StartOfWeek return a Carbon instance for start of the week 本周开始时间
func (Carbon) StartOfYear ¶
StartOfYear return a Carbon instance for start of the year 本年开始时间
func (Carbon) String ¶ added in v1.3.7
String output a string in date and time format, implement Stringer interface 实现 Stringer 接口
func (Carbon) SubCenturies ¶ added in v1.2.6
SubCenturies subtraction some centuries N个世纪前
func (Carbon) SubCenturiesNoOverflow ¶ added in v1.3.0
SubCenturiesNoOverflow subtraction some centuries without overflowing month N个世纪前(月份不溢出)
func (Carbon) SubCentury ¶ added in v1.2.6
SubCentury subtraction one century 1个世纪前
func (Carbon) SubCenturyNoOverflow ¶ added in v1.3.0
SubCenturyNoOverflow subtraction one century without overflowing month 1个世纪前(月份不溢出)
func (Carbon) SubDecadeNoOverflow ¶ added in v1.5.2
SubDecadeNoOverflow subtraction one decade without overflowing month 1个年代后(月份不溢出)
func (Carbon) SubDecades ¶ added in v1.5.2
SubDecades subtraction some decades N个年代后
func (Carbon) SubDecadesNoOverflow ¶ added in v1.5.2
SubDecadesNoOverflow subtraction some decades without overflowing month N个年代后(月份不溢出)
func (Carbon) SubDuration ¶ added in v1.2.4
SubDuration subtraction one duration 按照持续时长字符串减少时间,支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合
func (Carbon) SubMinutes ¶
SubMinutes subtraction some minutes N分钟前
func (Carbon) SubMonthNoOverflow ¶ added in v1.3.0
SubMonthNoOverflow subtraction one month without overflowing month 1个月前(月份不溢出)
func (Carbon) SubMonthsNoOverflow ¶ added in v1.3.0
SubMonthsNoOverflow subtraction some months without overflowing month N个月前(月份不溢出)
func (Carbon) SubQuarter ¶ added in v1.2.3
SubQuarter subtraction one quarter 1个季度前
func (Carbon) SubQuarterNoOverflow ¶ added in v1.3.0
SubQuarterNoOverflow subtraction one quarter without overflowing month 1个季度前(月份不溢出)
func (Carbon) SubQuarters ¶ added in v1.2.3
SubQuarters subtraction some quarters N个季度前
func (Carbon) SubQuartersNoOverflow ¶ added in v1.3.0
SubQuartersNoOverflow subtraction some quarters without overflowing month N个季度前(月份不溢出)
func (Carbon) SubSeconds ¶
SubSeconds subtraction some seconds N秒钟前
func (Carbon) SubYearNoOverflow ¶ added in v1.3.0
SubYearNoOverflow subtraction one year without overflowing month 1年前(月份不溢出)
func (Carbon) SubYearsNoOverflow ¶ added in v1.3.0
SubYearsNoOverflow subtraction some years without overflowing month N年前(月份不溢出)
func (Carbon) ToAnsicString ¶ added in v1.2.0
ToAnsicString output a string in ANSIC format 输出 ANSIC 格式字符串
func (Carbon) ToAtomString ¶ added in v1.2.0
ToAtomString output a string in ATOM format 输出 ATOM 格式字符串
func (Carbon) ToCookieString ¶ added in v1.2.0
ToCookieString output a string in COOKIE format 输出 COOKIE 格式字符串
func (Carbon) ToDateString ¶
ToDateString output a string in date format 输出日期字符串
func (Carbon) ToDateTimeString ¶
ToDateTimeString output a string in date and time format 输出日期时间字符串
func (Carbon) ToDayDateTimeString ¶ added in v1.2.0
ToDayDateTimeString output a string in day, date and time format 输出天数日期时间字符串
func (Carbon) ToFormatString ¶ added in v1.2.0
ToFormatString output a string by format 输出指定格式的时间字符串
func (Carbon) ToIso8601String ¶ added in v1.4.4
ToIso8601String output a string in ISO8601 format 输出 ISO8601 格式字符串
func (Carbon) ToKitchenString ¶ added in v1.2.0
ToKitchenString output a string in KITCHEN format 输出 KITCHEN 格式字符串
func (Carbon) ToLayoutString ¶ added in v1.4.4
ToLayoutString output a string by layout 输出指定布局的时间字符串
func (Carbon) ToMonthString ¶ added in v1.3.4
ToMonthString output a string in month format, i18n is supported 输出完整月份字符串,支持i18n
func (Carbon) ToRfc1036String ¶ added in v1.3.0
ToRfc1036String output a string in RFC1036 format 输出 RFC1036 格式字符串
func (Carbon) ToRfc1123String ¶ added in v1.3.0
ToRfc1123String output a string in RFC1123 format 输出 RFC1123 格式字符串
func (Carbon) ToRfc1123zString ¶ added in v1.4.5
ToRfc1123zString output a string in RFC1123z format 输出 RFC1123z 格式字符串
func (Carbon) ToRfc2822String ¶ added in v1.3.0
ToRfc2822String output a string in RFC2822 format 输出 RFC2822 格式字符串
func (Carbon) ToRfc3339String ¶ added in v1.3.0
ToRfc3339String output a string in RFC3339 format 输出 RFC3339 格式字符串
func (Carbon) ToRfc7231String ¶ added in v1.3.0
ToRfc7231String output a string in RFC7231 format 输出 RFC7231 格式字符串
func (Carbon) ToRfc822String ¶ added in v1.3.0
ToRfc822String output a string in RFC822 format 输出 RFC822 格式字符串
func (Carbon) ToRfc822zString ¶ added in v1.3.0
ToRfc822zString output a string in RFC822Z format 输出 RFC822Z 格式字符串
func (Carbon) ToRfc850String ¶ added in v1.3.0
ToRfc850String output a string in RFC850 format 输出 RFC850 格式字符串
func (Carbon) ToRssString ¶ added in v1.2.0
ToRssString output a string in RSS format 输出 RSS 格式字符串
func (Carbon) ToRubyDateString ¶ added in v1.2.0
ToRubyDateString output a string in ruby date format 输出 RubyDate 格式字符串
func (Carbon) ToShortDateString ¶ added in v1.4.4
ToShortDateString output a string in short date format 输出简写日期字符串
func (Carbon) ToShortDateTimeString ¶ added in v1.4.4
ToShortDateTimeString output a string in short date and time format 输出简写日期时间字符串
func (Carbon) ToShortMonthString ¶ added in v1.3.4
ToShortMonthString output a string in short month format, i18n is supported 输出缩写月份字符串,支持i18n
func (Carbon) ToShortTimeString ¶ added in v1.4.4
ToShortTimeString output a string in short time format 输出简写时间字符串
func (Carbon) ToShortWeekString ¶ added in v1.3.4
ToShortWeekString output a string in short week format, i18n is supported 输出缩写星期字符串,支持i18n
func (Carbon) ToString ¶ added in v1.2.0
ToString output a string in "2006-01-02 15:04:05.999999999 -0700 MST" format 输出"2006-01-02 15:04:05.999999999 -0700 MST"格式字符串
func (Carbon) ToTimeString ¶
ToTimeString output a string in time format 输出时间字符串
func (Carbon) ToTimestamp ¶
ToTimestamp output a timestamp with second, it is short for ToTimestampWithSecond 输出秒级时间戳, 是 ToTimestampWithSecond 的简写
func (Carbon) ToTimestampWithMicrosecond ¶ added in v1.2.3
ToTimestampWithMicrosecond output a timestamp with microsecond 输出微秒级时间戳
func (Carbon) ToTimestampWithMillisecond ¶ added in v1.2.3
ToTimestampWithMillisecond output a timestamp with millisecond 输出毫秒级时间戳
func (Carbon) ToTimestampWithNanosecond ¶ added in v1.2.3
ToTimestampWithNanosecond output a timestamp with nanosecond 输出纳秒级时间戳
func (Carbon) ToTimestampWithSecond ¶ added in v1.2.3
ToTimestampWithSecond output a timestamp with second 输出秒级时间戳
func (Carbon) ToUnixDateString ¶ added in v1.2.0
ToUnixDateString output a string in unix date format 输出 UnixDate 格式字符串
func (Carbon) ToW3cString ¶ added in v1.2.0
ToW3cString output a string in W3C format 输出 W3C 格式字符串
func (Carbon) ToWeekString ¶ added in v1.3.4
ToWeekString output a string in week format, i18n is supported 输出完整星期字符串,支持i18n
func (Carbon) Value ¶
Value the interface providing the Value method for package database/sql/driver
func (Carbon) WeekOfMonth ¶ added in v1.2.0
WeekOfMonth get week of month 获取本月的第几周
func (Carbon) WeekOfYear ¶ added in v1.2.0
WeekOfYear get week of year. see https://en.wikipedia.org/wiki/ISO_8601#Week_dates 获取本年的第几周
type Language ¶ added in v1.3.1
type Language struct {
// contains filtered or unexported fields
}
Language 定义 Language 结构体 define Language structure
func NewLanguage ¶ added in v1.3.1
func NewLanguage() *Language
NewLanguage return a new Language instance 初始化 Language 结构体
func (*Language) SetResources ¶ added in v1.3.4
SetResources set language resources 设置资源
type ToDateString ¶
type ToDateString struct {
Carbon
}
ToDateString define ToDateTimeString structure
func (ToDateString) MarshalJSON ¶
func (t ToDateString) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToDateString) UnmarshalJSON ¶ added in v1.4.3
func (t *ToDateString) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToDateTimeString ¶
type ToDateTimeString struct {
Carbon
}
ToDateTimeString define ToDateTimeString structure
func (ToDateTimeString) MarshalJSON ¶
func (t ToDateTimeString) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToDateTimeString) UnmarshalJSON ¶ added in v1.4.3
func (t *ToDateTimeString) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimeString ¶
type ToTimeString struct {
Carbon
}
ToTimeString define ToTimeString structure
func (ToTimeString) MarshalJSON ¶
func (t ToTimeString) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimeString) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimeString) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimestamp ¶
type ToTimestamp struct {
Carbon
}
ToTimestamp define ToTimestamp structure
func (ToTimestamp) MarshalJSON ¶
func (t ToTimestamp) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimestamp) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimestamp) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimestampWithMicrosecond ¶ added in v1.2.4
type ToTimestampWithMicrosecond struct {
Carbon
}
ToTimestampWithMicrosecond define ToTimestampWithMicrosecond structure
func (ToTimestampWithMicrosecond) MarshalJSON ¶ added in v1.2.4
func (t ToTimestampWithMicrosecond) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimestampWithMicrosecond) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimestampWithMicrosecond) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimestampWithMillisecond ¶ added in v1.2.4
type ToTimestampWithMillisecond struct {
Carbon
}
ToTimestampWithMillisecond define ToTimestampWithMillisecond structure
func (ToTimestampWithMillisecond) MarshalJSON ¶ added in v1.2.4
func (t ToTimestampWithMillisecond) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimestampWithMillisecond) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimestampWithMillisecond) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimestampWithNanosecond ¶ added in v1.2.4
type ToTimestampWithNanosecond struct {
Carbon
}
ToTimestampWithNanosecond define ToTimestampWithNanosecond structure
func (ToTimestampWithNanosecond) MarshalJSON ¶ added in v1.2.4
func (t ToTimestampWithNanosecond) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimestampWithNanosecond) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimestampWithNanosecond) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.
type ToTimestampWithSecond ¶ added in v1.2.4
type ToTimestampWithSecond struct {
Carbon
}
ToTimestampWithSecond define ToTimestampWithSecond structure
func (ToTimestampWithSecond) MarshalJSON ¶ added in v1.2.4
func (t ToTimestampWithSecond) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*ToTimestampWithSecond) UnmarshalJSON ¶ added in v1.4.3
func (t *ToTimestampWithSecond) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.