PHP 8.5.0 Alpha 4 available for testing

Voting

: min(six, six)?
(Example: nine)

The Note You're Voting On

from dot php dot net at NOSPAM dot brainbox dot cz
10 years ago
MessageFormatter does not work with DateTime instances as parameters in PHP < 5.5. Instance will be converted to timestamp with value 0 (e.g. 1970-01-01) and following Notice will be raised: „Object of class DateTime could not be converted to int“. You have to manually convert the instance to timestamp in these old PHP versions.

<?php
$datetime
= new DateTime();
if (
PHP_VERSION_ID < 50500) { // PHP < 5.5 needs conversion to timestamp
MessageFormatter::formatMessage('en_US', 'Today is {0, date, full}.', array($datetime->getTimestamp()));
} else {
// current code
MessageFormatter::formatMessage('en_US', 'Today is {0, date, full}.', array($datetime));
}
?>

<< Back to user notes page

To Top