PHP | IntlCalendar inDaylightTime() Function
The IntlCalendar::inDaylightTime() function is an inbuilt function in PHP which is used to check whether the object time is in Daylight Savings Time or not.
Syntax:
- Object oriented style
bool public IntlCalendar::inDaylightTime( void )
- Procedural style
bool intlcal_in_daylight_time( IntlCalendar $cal )
Parameters: This function accepts single parameter $cal which hold the resource of IntlCalendar object.
Return Value: This function returns TRUE if the date is in Daylight Savings Time and FALSE otherwise.
Below program illustrates the IntlCalendar::inDaylightTime() function in PHP:
Program:
<?php // Set the DateTime zone ini_set ( 'date.timezone' , 'Europe/Lisbon' ); // Create an instance of IntlCalendar $calendar = IntlCalendar::createInstance( 'Europe/Lisbon' ); // Check whether the object time is in // Daylight Savings Time or not var_dump( $calendar ->inDaylightTime()); // Set the month field of IntlCalendar $calendar ->set(IntlCalendar::FIELD_MONTH, 11); // Check whether the object time is in // Daylight Savings Time or not var_dump( $calendar ->inDaylightTime()); // Declare a IntlGregorianCalendar object $calendar = new IntlGregorianCalendar(2019, 8, 24, 12, 40, 10); // Check whether the object time is in // Daylight Savings Time or not var_dump( $calendar ->inDaylightTime()); // Set the date to DateTime object $calendar ->set(2019, 8, 24); // Check whether the object time is in // Daylight Savings Time or not var_dump( $calendar ->inDaylightTime()); ?> |
Output:
bool(true) bool(false) bool(true) bool(true)
Reference: https://www.php.net/manual/en/intlcalendar.indaylighttime.php
Please Login to comment...