+

PHP IntlCalendar setTime () function

Syntax:
  • Object Oriented Style
    bool IntlCalendar::setTime (float $date)
  • Procedural style
    bool intlcal_set_time (IntlCalendar $cal, float $date )
Parameters:This function uses two parameters as above and described below:
  • $cal:this parameter contains the IntlCalendar resource.
  • $date:this parameter contains the moment, represented by the number of milliseconds between the instant and the time of the epoch. This ignores leap seconds.
Return Value:This function returns TRUE on success and FALSE on failure.The following program illustrates the function IntlCalendar::setTime() in PHP:Program:  
// Set date, time zone ini_set ( `date.timezone` , ` Asia / Calcutta` );  
// Create a DateTime object $cal = IntlCalendar::fromDateTime ( `2019-03-21 09: 19: 29` );  
// Format the DateTime object echo IntlDateFormatter::formatObject ( $cal , IntlDateFormatter::FULL), "" ;  
// Declare a new IntlGregorianCalendar object $cal = new IntlGregorianCalendar (2019, 8, 22, 10, 30, 34);  
// Format the DateTime object echo IntlDateFormatter::formatObject ( $cal , IntlDateFormatter::FULL), "" ;  
// Set the DateTime object $cal -> setTime ( strtotime ( `2019-10-27 -05: 30: 00 GMT` ) * 1000);  
// Format the DateTime object echo IntlDateFormatter::formatObject ( $cal , IntlDateFormatter::FULL);  
?>
Exit:
Thursday, March 21, 2019 at 9:19:29 AM India Standard Time Sunday, September 22, 2019 at 10:30:34 AM India Standard Time Thursday, January 1, 1970 at 5:30:00 AM India Standard Time
Link: https://www.php.net/manual/en/intlcalendar .settime.php
Get Solution for free from DataCamp guru