本文整理匯總了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);
}