Saturday, July 13, 2024
HomeLanguagesPhpPHP | IntlCalendar inDaylightTime() Function

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments