Open In App

PHP | IntlCalendar getTime() Function

Last Updated : 25 Sep, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:

  • Object oriented style
    float IntlCalendar::getTime( void )
  • Procedural style
    float intlcal_get_time( IntlCalendar $cal )

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
  
// 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:

float(1569306894500)
float(1571747456000)
float(1553159969000)
float(1553159969000)

Reference: https://www.php.net/manual/en/intlcalendar.gettime.php


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads