PHP | IntlCalendar getTime() Function
Last Updated :
25 Sep, 2019
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:
Parameters: This function accepts single parameter $cal which holds the resource of IntlCalendar object.
Return Value: This function returns a floating point number representing the milliseconds elapsed since the epoch (1 Jan 1970 00:00:00 UTC).
Below program illustrates the IntlCalendar::getTime() function in PHP:
Program:
<?php
$calendar = IntlCalendar::createInstance();
var_dump( $calendar ->getTime());
$calendar = new IntlGregorianCalendar(2019, 9, 22, 12, 30, 56);
var_dump( $calendar ->getTime());
$calendar = IntlCalendar::fromDateTime( '2019-03-21 09:19:29' );
var_dump( $calendar ->getTime());
$calendar ->setTimeZone( 'GMT+05:30' );
var_dump( $calendar ->getTime());
?>
|
Output:
float(1569306894500)
float(1571747456000)
float(1553159969000)
float(1553159969000)
Reference: https://www.php.net/manual/en/intlcalendar.gettime.php
Share your thoughts in the comments
Please Login to comment...