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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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());
  
?>

chevron_right


Output:

bool(true)
bool(false)
bool(true)
bool(true)

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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.