本文整理汇总了PHP中float::format方法的典型用法代码示例。如果您正苦于以下问题:PHP float::format方法的具体用法?PHP float::format怎么用?PHP float::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类float
的用法示例。
在下文中一共展示了float::format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getShippedOn
public function getShippedOn()
{
if ($this->shippedOn) {
return $this->shippedOn->format('d-m-Y');
} else {
return false;
}
}
示例2: writeQTime
/**
* Writes a QTime for the given timestamp or DateTime object
*
* The QTime will only carry the number of milliseconds since midnight.
* This means you should probably only use this for times within the current
* day.
*
* If you pass a timestamp from any other day, it will write the number of
* milliseconds that passed since that day's midnight. Note that reading
* this number has no indication this is not the current day, so you're
* likely going to lose the day information and may end up with wrong dates.
*
* The QTime will be sent as the number of milliseconds since midnight,
* without any awareness of timezone or DST properties. Thus, writing this
* will assume it is relative to the current timezone. This means that the
* time "14:10:34.5108" will be 14h after midnight, irrespective of its
* actual timezone. The receiving side may not be aware of your local
* timezone, so it can only assume its own local timezone as a base.
*
* Make sure to use (i.e. convert via `setTimeZone()`) to the same timezone
* on both sides or consider using the `writeQDateTime()` method instead,
* which uses absolute time stamps and does not suffer from this.
*
* You can also pass a Unix timestamp to this function, this will be assumed
* to be relative to the local midnight timestamp. If you need more control
* over your timezone, consider passing a `DateTime` object instead.
*
* @param DateTime|float $timestamp
* @see self::writeQDateTime
*/
public function writeQTime($timestamp)
{
if ($timestamp instanceof \DateTime) {
$msec = $timestamp->format('H') * 3600000 + $timestamp->format('i') * 60000 + $timestamp->format('s') * 1000 + (int) ($timestamp->format('0.u') * 1000);
} else {
$msec = round(($timestamp - strtotime('midnight', (int) $timestamp)) * 1000);
}
$this->writer->writeUInt32BE($msec);
}