Change language

PHP IntlDateFormatter getCalendar () function

Syntax:
  • Object Oriented Style:
    int IntlDateFormatter::getCalendar (void )
  • Procedural style:
    int datefmt_get_calendar (IntlDateFormatter $fmt)
Parameters:This function takes one parameter, $fmt,which contains the formatter resource.Return value: this function returns the type of calendar used by the formatter. Formatter object: IntlDateFormatter::TRADITIONAL or IntlDateFormatter::GREGORIAN.The following programs illustrate the IntlDateFormatter::getCalendar() function in PHP:Program 1:  
// Create date formatter $formatter = datefmt_create ( ’en_US’ , IntlDateFormatter::FULL, IntlDateFormatter::FULL, ’ Asia / Kolkata’ , IntlDateFormatter::TRADITIONAL, " MM / dd / yyyy ");  
// Get the calendar type echo ’Calendar of formatter:’ . datefmt_get_calendar ( $formatter ). "" ;  
// Get the date / time value formatted as a string echo "Formatted calendar output:" . datefmt_format ( $formatter , 0). "" ;  
// Set the type of calendar used by the formatter datefmt_set_calendar ( $formatter , IntlDateFormatter::GREGORIAN);  
// Get the calendar type echo ’Calendar of formatter:’ . datefmt_get_calendar ( $formatter ). "" ;  
// Get the date / time value formatted as a string echo "First Formatted output is" . datefmt_format ( $formatter , 0);  
?>
Exit:
Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 1 First Formatted output is 01/01/1970
Program 2:

 
// Create a date formatter $formatter = datefmt_create ( ’en_US’ , IntlDateFormatter::FULL, IntlDateFormatter::FULL, ’Asia / Kolkata’ , IntlDateFormatter::TRADITIONAL, "MM / dd / yyyy");  
// Get the calendar type echo ’Calendar of formatter:’ . $formatter -> getCalendar(). "" ;  
// Get the date / time value formatted as a string echo "Formatted calendar output:" . $formatter -> format (0). "" ;  
// Set the type of calendar used by the formatter $formatter -> setCalendar (IntlDateFormatter::GREGORIAN);  
// Get the calendar type echo ’Calendar of formatter:’ . $formatter -> getCalendar(). "" ;  
// Get the date / time value formatted as a string echo "First Formatted output is" . $formatter -> format (0);  
?>
Exit:
Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 1 First Formatted output is 01/01/1970
Link: https://www.php.net/manual/en/intldateformatter.getcalendar.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method