Wednesday, October 15, 2025
HomeLanguagesPHP | IntlCalendar::__construct() Function

PHP | IntlCalendar::__construct() Function

The IntlCalendar::__construct() function is an inbuilt function in PHP which is used to create a private constructor for disallowing instantiation.

Syntax:

private IntlCalendar::__construct( void )

Parameters: This function does not accept any parameters.

Return Value: This function does not return any value.

Below program illustrates the IntlCalendar::__construct() function in PHP:

Program:




<?php
  
// Create an IntlCalendar from a DateTime object or string
$calendar = IntlCalendar::fromDateTime('2019-08-29 09:19:29');
  
// Add the date
$calendar->add(IntlCalendar::FIELD_YEAR, 5);
  
// Display the result date
echo IntlDateFormatter::formatObject($calendar), "\n";
  
// Add the date
$calendar->add(IntlCalendar::FIELD_YEAR, 10);
  
// Display the result output
echo IntlDateFormatter::formatObject($calendar), "\n";
  
// Add the date
$calendar->add(IntlCalendar::FIELD_HOUR_OF_DAY, 10);
  
// Display the result output
echo IntlDateFormatter::formatObject($calendar);
  
?>


Output:

Aug 29, 2024, 9:19:29 AM
Aug 29, 2034, 9:19:29 AM
Aug 29, 2034, 7:19:29 PM

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11891 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11952 POSTS0 COMMENTS
Shaida Kate Naidoo
6851 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS