本文整理汇总了PHP中CString::padStart方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::padStart方法的具体用法?PHP CString::padStart怎么用?PHP CString::padStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::padStart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: componentsInTimeZoneToTime
protected static function componentsInTimeZoneToTime($year, $month, $day, $hour, $minute, $second, $millisecond, $timeZone)
{
assert('self::areComponentsValid($year, $month, $day, $hour, $minute, $second, $millisecond)', vs(isset($this), get_defined_vars()));
assert('1000 <= $year && $year <= 9999', vs(isset($this), get_defined_vars()));
$strYear = CString::fromInt($year);
$strMonth = CString::fromInt($month);
$strDay = CString::fromInt($day);
$strHour = CString::padStart(CString::fromInt($hour), "0", 2);
$strMinute = CString::padStart(CString::fromInt($minute), "0", 2);
$strSecond = CString::padStart(CString::fromInt($second), "0", 2);
$dt = DateTime::createFromFormat("Y,m,d,H,i,s", "{$strYear},{$strMonth},{$strDay},{$strHour},{$strMinute},{$strSecond}", is_cstring($timeZone) ? new DateTimeZone($timeZone) : $timeZone->DTimeZone());
if (!is_object($dt)) {
assert('false', vs(isset($this), get_defined_vars()));
}
$UTime = $dt->getTimestamp();
$MTime;
if (!($UTime < 0 && $millisecond != 0)) {
$MTime = $millisecond;
} else {
$UTime++;
$MTime = $millisecond - 1000;
}
return new self($UTime, $MTime);
}
示例2: fromCharCodeEsc
/**
* Returns a character by its code point specified in an escaped fashion.
*
* For instance, "\u0041" would return "A".
*
* @param string $code The Unicode code point prefixed with "\u". The number of hexadecimal digits in the string
* should be four.
*
* @return string The Unicode character with the code point specified.
*/
public static function fromCharCodeEsc($code)
{
assert('is_cstring($code)', vs(isset($this), get_defined_vars()));
assert('CRegex::find($code, "/^\\\\\\\\u((?i)[0-9A-F]{4}(?<!FFFE|FFFF))\\\\z/")', vs(isset($this), get_defined_vars()));
return json_decode("\"\\u" . CString::padStart(CString::substr($code, 2), "0", 4) . "\"");
}