亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

刨刨 Carbon API

Yuqi / 1500人閱讀

摘要:介紹是對模塊的二次擴(kuò)展提供時間格式化,時間計算的功能官方主頁為地址為文件結(jié)構(gòu)目錄描述源文件源文件類的二次擴(kuò)展類主要用于時差計算類的二次擴(kuò)展類提供時間計算,格式化輸出的功能自定義異常文件夾語言本地化文件夾類的方法會用到

介紹

Carbon是對PHP DateTime模塊的二次擴(kuò)展;提供時間格式化,時間計算的功能;

官方主頁為 http://carbon.nesbot.com/;

Github地址為 https://github.com/briannesbitt/Carbon;

文件結(jié)構(gòu)
目錄 描述
-- src Carbon源文件
-- srcCarbon Carbon源文件
-- srcCarbonCarbonInterval.php DateInterval類的二次擴(kuò)展類CarbonInterval;主要用于時差計算;
-- srcCarbonCarbon.php DateTime類的二次擴(kuò)展類Carbon;提供時間計算,格式化輸出的功能;
-- srcCarbonExceptions 自定義異常文件夾
-- srcCarbonLang 語言本地化文件夾;Carbon類的diffForHumans方法會用到;
-- tests Carbon測試用例文件
-- testsAbstractTestCase.php 所有測試文件的父類;提供了執(zhí)行前初始化執(zhí)行后清理的功能, 及其它公共的API;
-- testsCarbon 針對srcCarbonCarbon.php的測試用例組
-- testsCarbonInterval 針對srcCarbonCarbonInterval.php的測試用例組
-- testsLocalization 針對srcCarbonLang的測試用例組
API 細(xì)則

本篇涉及 APICarbon 1.22.1 版本;

Carbon 用途:生成Carbon實例
方法名 參數(shù) 描述
__construct $time(null), $tz(null) 根據(jù)格式化時間字符串和指定時區(qū), 創(chuàng)建Carbon實例
instance(static) DateTime $dt 根據(jù) DateTime實例創(chuàng)建Carbon實例
parse(static) $time(null), $tz(null) 根據(jù)格式化時間字符串和指定時區(qū), 創(chuàng)建Carbon實例
create(static) $year(null), $month(null), $day(null), $hour(null), $minute(null), $second(null), $tz(null) 根據(jù)日期和時間創(chuàng)建Carbon實例 如果指定參數(shù)為null,會默認(rèn)使用當(dāng)前時間的對應(yīng)值
createSafe(static) $year(null), $month(null), $day(null), $hour(null), $minute(null), $second(null), $tz(null) 根據(jù)日期和時間創(chuàng)建Carbon實例 如果指定參數(shù)為null,會默認(rèn)使用當(dāng)前時間的對應(yīng)值; 指定參數(shù)不符合規(guī)范,會返回異常;
createFromDate(static) $year(null), $month(null), $day(null), $tz(null) 根據(jù)日期創(chuàng)建Carbon實例如果指定參數(shù)為null,會默認(rèn)使用當(dāng)前時間的對應(yīng)值
createFromTime(static) $hour(null), $minute(null), $minute(null), $tz(null) 根據(jù)時間創(chuàng)建Carbon實例如果指定參數(shù)為null,會默認(rèn)使用當(dāng)前時間的對應(yīng)值
createFromFormat(static) $format, $time, $tz(null) 根據(jù)時間字符串及其對應(yīng)的format字符串創(chuàng)建Carbon實例
createFromTimestamp(static) $timestamp, $tz(null) 根據(jù)時間戳和指定時區(qū), 創(chuàng)建Carbon實例
createFromTimestampUTC(static) $timestamp 根據(jù)時間戳和utc時區(qū), 創(chuàng)建Carbon實例
now(static) $tx(null) 根據(jù)當(dāng)前時間創(chuàng)建Carbon實例
today(static) $tx(null) 根據(jù)當(dāng)前時間創(chuàng)建Carbon實例,時間重置為 0時0分0秒
tomorrow(static) $tx(null) 根據(jù)當(dāng)前時間,加一天,創(chuàng)建Carbon實例
yesterday(static) $tx(null) 根據(jù)當(dāng)前時間, 減一天, 創(chuàng)建Carbon實例
minValue(static) "" 創(chuàng)建系統(tǒng)支持的最小時間,并返回Carbon實例
maxValue(static) "" 創(chuàng)建系統(tǒng)支持的最大時間,并返回Carbon實例
copy "" 復(fù)制當(dāng)前Carbon實例
fromSerialized(static) $value 解析序列化字符串,創(chuàng)建Carbon實例
用途:修改Carbon實例
方法名 參數(shù) 描述
setDate $year, $month, $day 設(shè)置當(dāng)前實例的年,月,日
setDateTime $year, $month, $day, $hour, $minute, $second(0) 設(shè)置當(dāng)前實例的年,月,日,時,分,秒
setTimeFromTimeString $time 根據(jù) H:i:s 字符串設(shè)置當(dāng)前實例時間
timestamp $value 根據(jù)時間戳設(shè)置當(dāng)前實例時間
second $value 設(shè)置當(dāng)前實例時間指定秒
minute $value 設(shè)置當(dāng)前實例時間指定分鐘
hour $value 設(shè)置當(dāng)前實例時間指定小時
day $value 設(shè)置當(dāng)前實例時間指定天
month $value 設(shè)置當(dāng)前實例時間指月份
year $value 設(shè)置當(dāng)前實例時間指定年份
startOfDay "" 重置當(dāng)前實例時間為 0時0分0秒
endOfDay "" 重置當(dāng)前實例時間為 23時59分59秒
startOfWeek "" 重置當(dāng)前實例時間為 本周的第一天,同時設(shè)置 0時0分0秒
endOfWeek "" 重置當(dāng)前實例時間為 本周的最后一天,同時設(shè)置 23時59分59秒
startOfMonth "" 重置當(dāng)前實例時間為 本月第一天,同時設(shè)置 0時0分0秒
endOfMonth "" 重置當(dāng)前實例時間為 本月最后一天,同時設(shè)置 23時59分59秒
startOfQuarter "" 重置當(dāng)前實例時間為 本季度第一天,同時設(shè)置 0時0分0秒
endOfQuarter "" 重置當(dāng)前實例時間為 本季度最后一天,同時設(shè)置 23時59分59秒
startOfYear "" 重置當(dāng)前實例時間為 本年第一天,同時設(shè)置 0時0分0秒
endOfYear "" 重置當(dāng)前實例時間為 本年最后一天,同時設(shè)置 23時59分59秒
startOfDecade "" 重置當(dāng)前實例時間為 所在十年的第一天,同時設(shè)置 0時0分0秒
endOfDecade "" 重置當(dāng)前實例時間為 所在十年的最后一天,同時設(shè)置 23時59分59秒
startOfCentury "" 重置當(dāng)前實例時間為 本世紀(jì)的第一天,同時設(shè)置 0時0分0秒
endOfCentury "" 重置當(dāng)前實例時間為 本世紀(jì)的最后一天,同時設(shè)置 23時59分59秒
next $dayOfWeek(null) 重置當(dāng)前實例時間為 下一個指定dayOfWeek,同時設(shè)置 0時0分0秒
previous $dayOfWeek(null) 重置當(dāng)前實例時間為 上一個指定dayOfWeek,同時設(shè)置 0時0分0秒
nextWeekday "" 重置當(dāng)前實例時間為 下一個工作日,同時設(shè)置 0時0分0秒
previousWeekday "" 重置當(dāng)前實例時間為 上一個工作日,同時設(shè)置 0時0分0秒
nextWeekendDay "" 重置當(dāng)前實例時間為 下一個雙休日,同時設(shè)置 0時0分0秒
previousWeekendDay "" 重置當(dāng)前實例時間為 上一個雙休日,同時設(shè)置 0時0分0秒
firstOfMonth $dayOfWeek(null) 重置當(dāng)前實例時間為 本月第一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
nthOfMonth $nth, $dayOfWeek 重置當(dāng)前實例時間為 本月第n周的指定dayOfWeek,同時設(shè)置 0時0分0秒
lastOfMonth $dayOfWeek(null) 重置當(dāng)前實例時間為 本月最后一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
firstOfQuarter $dayOfWeek(null) 重置當(dāng)前實例時間為 當(dāng)前季度第一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
nthOfQuarter $nth, $dayOfWeek 重置當(dāng)前實例時間為 當(dāng)前季度第n周的指定dayOfWeek,同時設(shè)置 0時0分0秒
lastOfQuarter $dayOfWeek(null) 重置當(dāng)前實例時間為 當(dāng)前季度最后一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
firstOfYear $dayOfWeek(null) 重置當(dāng)前實例時間為 本年第一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
nthOfYear $nth, $dayOfWeek 重置當(dāng)前實例時間為 本年第n周的指定dayOfWeek,同時設(shè)置 0時0分0秒
lastOfYear $dayOfWeek(null) 重置當(dāng)前實例時間為 本年最后一周的指定dayOfWeek,同時設(shè)置 0時0分0秒
average Carbon $dt 重置當(dāng)前實例時間為 與指定Carbon對象的中間時刻
modify $modify modify字符串重置當(dāng)前實例時間
用途:格式化時間
方法名 參數(shù) 描述
__toString "" 按變量$toStringFormat的格式輸出
toDateString "" 日期格式化輸出
toTimeString "" 時間格式化輸出
toDateTimeString "" 日期時間格式化輸出
toDayDateTimeString "" 格式化輸出如 "Fri, Jan 3, 2013 10:50 PM"
toAtomString "" 格式化輸出如 "2012-10-20T14:12:26+00:00"
toCookieString "" 格式化輸出如 "Friday, 02-Jan-2012 14:20:39 UTC"
toIso8601String "" toAtomString
toRfc822String "" 格式化輸出如 "Mon, 15 Aug 05 15:52:01 +0000"
toRfc850String "" 格式化輸出如 "Monday, 15-Aug-05 15:52:01 UTC"
toRfc1036String "" 格式化輸出如 "2005-08-15T15:52:01+0000"
toRfc1123String "" 格式化輸出如 "Mon, 15 Aug 2005 15:52:01 +0000"
toRfc2822String "" 格式化輸出如 "Mon, 15 Aug 05 15:52:01 +0000"
toRfc3339String "" toAtomString
toRssString "" 格式化輸出如 "Mon, 15 Aug 2005 15:52:01 +0000"
toW3cString "" 格式化輸出如 "2005-08-15T15:52:01+00:00"
toFormattedDateString "" 格式化輸出如 "Jan 11, 1999"
formatLocalized $format 指定格式本地化輸出
用途:時間判斷
方法名 參數(shù) 描述
eq Carbon $dt 判斷當(dāng)前Carbon實例與指定Carbon對象時間是否一樣
equalTo Carbon $dt eq 方法
ne Carbon $dt 判斷當(dāng)前Carbon實例與指定Carbon對象時間是否不相同
notEqualTo Carbon $dt ne 方法
gt Carbon $dt 判斷當(dāng)前Carbon實例是否大于指定Carbon對象時間
greaterThan Carbon $dt gt 方法
gte Carbon $dt 判斷當(dāng)前Carbon實例是否大于等于指定Carbon對象時間
greaterThanOrEqualTo Carbon $dt gte 方法
lt Carbon $dt 判斷當(dāng)前Carbon實例是否小于指定Carbon對象時間
lessThan Carbon $dt lt 方法
lte Carbon $dt 判斷當(dāng)前Carbon實例是否小于等于指定Carbon對象時間
lessThanOrEqualTo Carbon $dt lte 方法
between Carbon $dt1, Carbon $dt2, $equal(true) 判斷當(dāng)前Carbon實例是否在指定Carbon對象時間之間, 第三個參數(shù)表示是否可以等于指定Carbon對象
min Carbon $dt 獲取當(dāng)前實例與指定Carbon對象中,最小的對象
minimum Carbon $dt min
max Carbon $dt 獲取當(dāng)前實例與指定Carbon對象中,最大的對象
maximum Carbon $dt max
closest Carbon $dt1, Carbon $dt2 獲取最接近當(dāng)前實例時間的Carbon對象
farthest Carbon $dt1, Carbon $dt2 獲取最不接近當(dāng)前實例時間的Carbon對象
isSameAs $format, Carbon $dt 判斷當(dāng)前實例與指定Carbon對象的format格式化結(jié)果是否相同
isSameDay Carbon $dt 判斷當(dāng)前實例與指定Carbon對象是否是同一天
isSameMonth Carbon $dt(null), $ofSameYear(false) 判斷當(dāng)前實例與指定Carbon對象月份是否相同
isBirthday Carbon $dt 判斷當(dāng)前實例與指定Carbon對象月日數(shù)是否相同
isSameYear Carbon $dt 判斷當(dāng)前實例與指定Carbon對象年份是否相同
isSunday "" 判斷當(dāng)前實例是否是周日
isMonday "" 判斷當(dāng)前實例是否是周一
isTuesday "" 判斷當(dāng)前實例是否是周二
isWednesday "" 判斷當(dāng)前實例是否是周三
isThursday "" 判斷當(dāng)前實例是否是周四
isFriday "" 判斷當(dāng)前實例是否是周五
isSaturday "" 判斷當(dāng)前實例是否是周六
isYesterday "" 判斷當(dāng)前實例是否是昨天
isToday "" 判斷當(dāng)前實例是否是今天
isTomorrow "" 判斷當(dāng)前實例是否是明天
isWeekday "" 判斷當(dāng)前實例是否屬于工作日
isWeekend "" 判斷當(dāng)前實例是否屬于周末雙休
isLastWeek "" 判斷當(dāng)前實例是否屬于上周
isNextWeek "" 判斷當(dāng)前實例是否屬于下一周
isLastMonth "" 判斷當(dāng)前實例是否屬于上一個月
isCurrentMonth "" 判斷當(dāng)前實例是否屬于當(dāng)前月
isNextMonth "" 判斷當(dāng)前實例是否屬于下一個月
isLastYear "" 判斷當(dāng)前實例是否屬于去年
isCurrentYear "" 判斷當(dāng)前實例是否屬于當(dāng)前年
isNextYear "" 判斷當(dāng)前實例是否屬于下一年
isLeapYear "" 判斷當(dāng)前實例是否屬于閏年
isLongYear "" 判斷當(dāng)前實例是否屬于長年,即一年不只有52個星期
isPast "" 判斷當(dāng)前實例是否屬于過去
isFuture "" 判斷當(dāng)前實例是否屬于未來
用途:時間計算
方法名 參數(shù) 描述
addSecond $value(1) 當(dāng)前實例添加指定數(shù)量的秒數(shù),返回當(dāng)前實例
subSecond $value(1) 當(dāng)前實例減去指定數(shù)量的秒數(shù),返回當(dāng)前實例
addSeconds $value addSecond
subSeconds $value subSecond
addMinute $value(1) 當(dāng)前實例添加指定數(shù)量的分鐘數(shù),返回當(dāng)前實例
subMinute $value(1) 當(dāng)前實例減去指定數(shù)量的分鐘數(shù),返回當(dāng)前實例
addMinutes $value addMinute
subMinutes $value subMinute
addHour $value(1) 當(dāng)前實例添加指定數(shù)量的小時數(shù),返回當(dāng)前實例
subHour $value(1) 當(dāng)前實例減去指定數(shù)量的小時數(shù),返回當(dāng)前實例
addHours $value addHour
subHours $value subHour
addDay $value(1) 當(dāng)前實例添加指定數(shù)量的天數(shù),返回當(dāng)前實例
subDay $value(1) 當(dāng)前實例減去指定數(shù)量的天數(shù),返回當(dāng)前實例
addDays $value addDay
subDays $value subDay
addWeekday $value(1) 當(dāng)前實例添加指定數(shù)量的工作日數(shù),返回當(dāng)前實例
subWeekday $value(1) 當(dāng)前實例減去指定數(shù)量的工作日數(shù),返回當(dāng)前實例
addWeekdays $value addWeekday
subWeekdays $value subWeekday
addWeek $value(1) 當(dāng)前實例添加指定數(shù)量的星期數(shù),返回當(dāng)前實例
subWeek $value(1) 當(dāng)前實例減去指定數(shù)量的星期數(shù),返回當(dāng)前實例
addWeeks $value addWeek
subWeeks $value subWeek
addMonth $value(1) 當(dāng)前實例添加指定數(shù)量的月數(shù),返回當(dāng)前實例
subMonth $value(1) 當(dāng)前實例減去指定數(shù)量的月數(shù),返回當(dāng)前實例
addMonths $value addMonth
subMonths $value subMonth
addMonthWithOverflow(1) $value(1) 當(dāng)前實例添加指定數(shù)量的月數(shù)(可溢出),返回當(dāng)前實例
subMonthWithOverflow(1) $value(1) 當(dāng)前實例添加指定數(shù)量的月數(shù)(可溢出),返回當(dāng)前實例
addMonthsWithOverflow $value addMonthWithOverflow
subMonthsWithOverflow $value subMonthWithOverflow
addMonthNoOverflow(1) $value(1) 當(dāng)前實例添加指定數(shù)量的月數(shù)(不可溢出),返回當(dāng)前實例
subMonthNoOverflow(1) $value(1) 當(dāng)前實例添加指定數(shù)量的月數(shù)(不可溢出),返回當(dāng)前實例
addMonthsNoOverflow $value addMonthNoOverflow
subMonthsNoOverflow $value subMonthNoOverflow
addQuarter(1) $value(1) 當(dāng)前實例添加指定數(shù)量的季度數(shù),返回當(dāng)前實例
subQuarter(1) $value(1) 當(dāng)前實例減去指定數(shù)量的季度數(shù),返回當(dāng)前實例
addQuarters $value addQuarter
subQuarters $value subQuarter
addYear(1) $value(1) 當(dāng)前實例添加指定數(shù)量的年數(shù),返回當(dāng)前實例
subYear(1) $value(1) 當(dāng)前實例減去指定數(shù)量的年數(shù),返回當(dāng)前實例
addYears $value addYear
subYears $value subYear
addCentury(1) $value(1) 當(dāng)前實例添加指定數(shù)量的世紀(jì)數(shù),返回當(dāng)前實例
subCentury(1) $value(1) 當(dāng)前實例減去指定數(shù)量的世紀(jì)數(shù),返回當(dāng)前實例
addCenturies $value addCentury
subCenturies $value subCentury
用途:時間差值比較
方法名 參數(shù) 描述
diffInSeconds Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的秒數(shù)差,前者 - 后者; abs表示是否返回絕對值
secondsSinceMidnight "" 獲取當(dāng)前實例時間的 0時0分0秒 與當(dāng)前實例時間的秒差
secondsUntilEndOfDay "" 獲取當(dāng)前實例時間的 23時59分59秒 與當(dāng)前實例時間的秒差
diffInMinutes Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的分鐘差, 取整
diffInHours Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的小時差, 取整
diffInHoursFiltered Closure $callback, Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的(通過回調(diào)函數(shù)較驗的)小時差, 取整
diffInDays Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的天數(shù)差, 取整
diffInDaysFiltered Closure $callback, Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的(通過回調(diào)函數(shù)較驗的)天數(shù)差, 取整
diffInWeekdays Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的工作日數(shù)差, 取整
diffInWeekendDays Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的雙休日數(shù)差, 取整
diffInWeeks Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的星期數(shù)差, 取整
diffInMonths Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的月數(shù)差, 取整
diffInYears Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的年數(shù)差, 取整
diffFiltered CarbonInterval $ci, Closure $callback, Carbon $dt(null), $abs(true) 獲取指定Carbon對象與當(dāng)前實例時間的(通過回調(diào)函數(shù)較驗的)$ci差, 取整
diffForHumans Carbon $other(null), $absolute(false), $short(false) 獲取指定Carbon對象與當(dāng)前實例時間的時間差,以便于人類閱讀的格式呈現(xiàn)
用途:Getter & Setter
方法名 參數(shù) 描述
getDays(static) "" 獲取days of the week
getWeekStartsAt(static) "" 獲取一周的第一天
setWeekStartsAt(static) $day 設(shè)置一周的第一天
getWeekEndsAt(static) "" 獲取一周的最后一天
setWeekEndsAt(static) $day 設(shè)置一周的最后一天
getWeekendDays(static) "" 獲取雙休日(數(shù)組)
setWeekendDays(static) $days 設(shè)置雙休日
getTranslator(static) "" 獲取translator實例
setTranslator(static) TranslatorInterface $translator 設(shè)置translator實例
getLocale(static) "" 獲取當(dāng)前本地化語言
setLocale(static) $locale 設(shè)置當(dāng)前本地化語言
timezone $value 設(shè)置時區(qū)
tz $value 設(shè)置時區(qū)
setTimezone $value 設(shè)置時區(qū)
setToStringFormat(static) $format 設(shè)置變量$toStringFormat
resetToStringFormat(static) "" 設(shè)置變量$toStringFormat為默認(rèn)值
setTestNow(static) $testNow(null) 設(shè)置變量$testNow,測試專用,初始化時的$now
getTestNow(static) "" 獲取變量$testNow
hasTestNow(static) "" 判斷$testNow是否為空
用途:其它
方法名 參數(shù) 描述
setUtf8(static) $utf8 設(shè)置是否采用 utf8 編碼方式
getLastErrors(static) "" 獲取無效時間的錯誤格式模板
serialize "" 返回當(dāng)前實例的序列化字符串
hasRelativeKeywords(static) $time 判斷字符串中是否有指定的關(guān)鍵字
shouldOverflowMonths(static) "" 獲取變量$monthsOverflow
useMonthsOverflow(static) $monthsOverflow(true) 設(shè)置變量$monthsOverflow
resetMonthsOverflow(static) "" 重置變量$monthsOverflowtrue
__get $name 魔術(shù)方法
__isset $name 魔術(shù)方法
__set $name, $value 魔術(shù)方法
CarbonInterval 用途:生成CarbonInterval實例
方法名 參數(shù) 描述
__construct $years(1), $months(null), $weeks(null), $days(null), $hours(null), $minutes(null), $seconds(null) 創(chuàng)建CarbonInterval實例
create(static) $years(1), $months(null), $weeks(null), $days(null), $hours(null), $minutes(null), $seconds(null) 創(chuàng)建CarbonInterval實例
second(static) $value 創(chuàng)建 CarbonInterval 實例
seconds(static) $value 創(chuàng)建 CarbonInterval 實例
minute(static) $value 創(chuàng)建 CarbonInterval 實例
minutes(static) $value 創(chuàng)建 CarbonInterval 實例
hour(static) $value 創(chuàng)建 CarbonInterval 實例
hours(static) $value 創(chuàng)建 CarbonInterval 實例
day(static) $value 創(chuàng)建 CarbonInterval 實例
days(static) $value 創(chuàng)建 CarbonInterval 實例
dayz(static) $value 創(chuàng)建 CarbonInterval 實例
week(static) $value 創(chuàng)建 CarbonInterval 實例
weeks(static) $value 創(chuàng)建 CarbonInterval 實例
month(static) $value 創(chuàng)建 CarbonInterval 實例
months(static) $value 創(chuàng)建 CarbonInterval 實例
year(static) $value 創(chuàng)建 CarbonInterval 實例
years(static) $value 創(chuàng)建 CarbonInterval 實例
instance(static) $value 創(chuàng)建 CarbonInterval 實例
用途:本地化
方法名 參數(shù) 描述
translator(static) "" 初始化translator實例
getTranslator(static) "" 獲取translator實例
setTranslator(static) TranslatorInterface $translator 設(shè)置translator實例
getLocale(static) "" 獲取當(dāng)前本地化語言
setLocale(static) $locale 設(shè)置當(dāng)前本地化語言
用途:計算
方法名 參數(shù) 描述
add DateInterval $interval 將指定DateInterval的時間疊加到當(dāng)前實例
用途:格式化
方法名 參數(shù) 描述
spec "" 獲取規(guī)范的間隔描述字符串
forHumans "" 獲取便于人類閱讀的間隔描述字符串
__toString "" forHumans
用途:其它
方法名 參數(shù) 描述
__get "" 魔術(shù)方法;可操作變量有years/months/dayz/hours/minutes/seconds/weeks/daysExcludeWeeks/dayzExcludeWeeks
__set "" 魔術(shù)方法;可操作變量有years/months/dayz/hours/minutes/seconds/weeks/daysExcludeWeeks/dayzExcludeWeeks
__call "" 魔術(shù)方法;可操作方法有years/year/months/month/weeks/week/days/dayz/day/hours/hour/minutes/minute/seconds/second
weeksAndDays $weeks, $days 為當(dāng)前實例的dayz變量賦值為($weeks * Carbon::DAYS_PER_WEEK) + $days

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://www.ezyhdfw.cn/yun/22985.html

相關(guān)文章

  • 使用 Carbon 計算時間差

    摘要:它是專門用來處理和時間相關(guān)的類,除了這里用到的實例化時間計算時間等,還有很多實用的功能,在參考資料中有相關(guān)鏈接,可以查看。 導(dǎo)語 這個需求是這樣的,我的電飯鍋有定時功能,第二天早上想要喝粥的話,就要設(shè)置倒計時,每次就要算一下要設(shè)置多少時間,干脆就寫個代碼好了。很簡單的功能,不值得寫一篇,另一個目的其實是記錄一下從開發(fā)到提交 GitHub 的流程。代碼可查看 GitHub。 本地開發(fā) 先...

    LinkedME2016 評論0 收藏0
  • PHP 開發(fā)者應(yīng)了解的 24 個庫

    摘要:下面是一個例子這個庫要求你至少安裝了和其中的一個,這可能意味著,在大多數(shù)主機(jī)提供商提供的主機(jī)上它可能用不了。借助它,你可以忘記如何書寫乏味的有一個姊妹庫叫,是一個基于的實現(xiàn)。 showImg(http://segmentfault.com/img/bVbJml); 作為一個PHP開發(fā)者,現(xiàn)在是一個令人激動的時刻。每天有許許多多有用的庫分發(fā)出來,在 Github 上很容易發(fā)現(xiàn)和使用這些庫...

    0x584a 評論0 收藏0
  • [轉(zhuǎn)+] Carbon中文文檔

    摘要:原文地址中文文檔介紹是的日期處理類庫。例如作者所在的時區(qū)為東京時間減小時,因此在下午一點(diǎn)后。最后提到的這兩個方法都是處理時間戳的。以下是當(dāng)前支持的時間轉(zhuǎn)換字值得注意的是像和方法等相關(guān)的修改會把日期的時間部分設(shè)置成。 原文地址 : Carbon中文文檔 介紹 Carbon 是php的日期處理類庫(A simple PHP API extension for DateTime.)。 Car...

    cyqian 評論0 收藏0
  • Carbon中文文檔

    摘要:是的日期處理類庫。另外可以默認(rèn)設(shè)置方法所要顯示的時間日期格式。一些特殊的過濾方法,像和可以幫助你過濾時間差中的或者一個自定義的時間間隔。對于人們來說一月前比天前更加易與理解。中定義了以下常量。 Introduction Carbon 是php的日期處理類庫(A simple PHP API extension for DateTime.)。Carbon 繼承了PHP的 Datetime...

    banana_pi 評論0 收藏0
  • Laravel 的十八個最佳實踐

    摘要:本文翻譯改編自的十八個最佳實踐這篇文章并不是什么由改編的原則模式等。只是為了讓你注意你在現(xiàn)實生活的項目中最常忽略的內(nèi)容。單一職責(zé)原則正在幫助你避免重復(fù)。當(dāng)然,這也包括了模板的范圍等。此外,也擁有很棒的內(nèi)置工具,比如軟刪除事件范圍等。 showImg(https://segmentfault.com/img/remote/1460000015166532); 本文翻譯改編自 Larave...

    gitmilk 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<