当前位置: 首页>>代码示例>>PHP>>正文


PHP CString::padStart方法代码示例

本文整理汇总了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);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:24,代码来源:CTime.php

示例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) . "\"");
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:16,代码来源:CUString.php


注:本文中的CString::padStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。