代码拉取完成,页面将自动刷新
同步操作将从 dromara/carbon 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Currently only
200
years from1900
to2100
are supported
Gregorian
calendar to Lunar
calendar// Get Lunar year of animal
carbon.Parse("2020-08-05 13:14:15").Lunar().Animal() // 鼠
// Get lunar festival
carbon.Parse("2021-02-12").Lunar().Festival() // 春节
// Get lunar year
carbon.Parse("2020-08-05").Lunar().Year() // 2020
// Get lunar month
carbon.Parse("2020-08-05").Lunar().Month() // 6
// Get lunar leap month
carbon.Parse("2020-08-05").Lunar().LeapMonth() // 4
// Get lunar day
carbon.Parse("2020-08-05").Lunar().Day() // 16
// Get lunar hour
carbon.Parse("2020-08-05").Lunar().Hour() // 13
// Get lunar minute
carbon.Parse("2020-08-05").Lunar().Minute() // 14
// Get lunar second
carbon.Parse("2020-08-05").Lunar().Second() // 15
// Get lunar date and time string
carbon.Parse("2020-08-05").Lunar().String() // 2020-06-16
fmt.Printf("%s", carbon.Parse("2020-08-05").Lunar()) // 2020-06-16
// Get lunar year as string
carbon.Parse("2020-08-05").Lunar().ToYearString() // 二零二零
// Get lunar month as string
carbon.Parse("2020-08-05").Lunar().ToMonthString() // 六月
// Get lunar leap month as string
carbon.Parse("2020-04-23").Lunar().ToMonthString() // 闰四月
// Get lunar week as string
carbon.Parse("2020-04-23").Lunar().ToWeekString() // 周四
// Get lunar day as string
carbon.Parse("2020-08-05").Lunar().ToDayString() // 十六
// Get lunar date as string
carbon.Parse("2020-08-05").Lunar().ToDateString() // 二零二零年六月十六
Lunar
calendar to Gregorian
calendar// Convert the Lunar Calendar December 11, 2023 to the gregorian calendar
carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
// Convert lunar calendar February 11, 2023 to gregorian calendar
carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2024-03-02 00:00:00
// Convert the Lunar Calendar Leap February 11, 2024 to the gregorian calendar
carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
// Whether is a valid lunar date
carbon.Parse("0000-00-00").Lunar().IsValid() // false
carbon.Parse("2020-08-05").Lunar().IsValid() // true
// Whether is a lunar leap year
carbon.Parse("2020-08-05").Lunar().IsLeapYear() // true
// Whether is a lunar leap month
carbon.Parse("2020-08-05").Lunar().IsLeapMonth() // false
// Whether is a lunar year of the rat
carbon.Parse("2020-08-05").Lunar().IsRatYear() // true
// Whether is a lunar year of the ox
carbon.Parse("2020-08-05").Lunar().IsOxYear() // false
// Whether is a lunar year of the tiger
carbon.Parse("2020-08-05").Lunar().IsTigerYear() // false
// Whether is a lunar year of the rabbit
carbon.Parse("2020-08-05").Lunar().IsRabbitYear() // false
// Whether is a lunar year of the dragon
carbon.Parse("2020-08-05").Lunar().IsDragonYear() // false
// Whether is a lunar year of the snake
carbon.Parse("2020-08-05").Lunar().IsSnakeYear() // false
// Whether is a lunar year of the horse
carbon.Parse("2020-08-05").Lunar().IsHorseYear() // false
// Whether is a lunar year of the goat
carbon.Parse("2020-08-05").Lunar().IsGoatYear() // false
// Whether is a lunar year of the monkey
carbon.Parse("2020-08-05").Lunar().IsMonkeyYear() // false
// Whether is a lunar year of the rooster
carbon.Parse("2020-08-05").Lunar().IsRoosterYear() // false
// Whether is a lunar year of the dog
carbon.Parse("2020-08-05").Lunar().IsDogYear() // false
// Whether is a lunar year of the dig
carbon.Parse("2020-08-05").Lunar().IsPigYear() // false
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。