PHP | IntlCalendar getTime() Function
Last Updated :
25 Sep, 2019
Improve
The IntlCalendar::getTime() function is an inbuilt function in PHP which is used to return the time currently represented by the object. The time is expressed in terms of milliseconds since the epoch.
Syntax:
php
- Object oriented style
float IntlCalendar::getTime( void )
- Procedural style
float intlcal_get_time( IntlCalendar $cal )
<?php
// Create an instance of calendar
$calendar = IntlCalendar::createInstance();
// Get the current time
var_dump($calendar->getTime());
// Create a new IntlGregorianCalendar
$calendar = new IntlGregorianCalendar(2019, 9, 22, 12, 30, 56);
// Get the current time
var_dump($calendar->getTime());
// Create a DateTime object
$calendar = IntlCalendar::fromDateTime('2019-03-21 09:19:29');
// Get the current time
var_dump($calendar->getTime());
// Set the timezone
$calendar->setTimeZone('GMT+05:30');
// Get the current time
var_dump($calendar->getTime());
?>
Output:
Reference: https://www.php.net/manual/en/intlcalendar.gettime.php
float(1569306894500) float(1571747456000) float(1553159969000) float(1553159969000)