Change language

PHP IntlCalendar fieldDifference () function

Syntax:
  • OO style:
    int IntlCalendar::fieldDifference (float  $when, int $field)
  • Procedural style:
    int intlcal_field_difference (IntlCalendar $cal, float $when, int $field)
Parameters:
  • $cal:this parameter contains the name of the IntlCalendar resource.
  • $when:this parameter contains the time with which compares the quantity represented by the field.
  • $field:this parameter contains a field representing the quantity to compare.
Returned value: this function returns the time difference in units associated with the specified field on success, or FALSE on error.The following program illustrates the IntlCalendar::fieldDifference() function in PHP:Program :  
// Set time zone ini_set ( ’date.timezone’ , ’Asia / Calcutta’ );  
// Get time from calendar $calendar1 = IntlCalendar::fromDateTime ( ’2018-12-21 09 : 30: 25’ ); $calendar2 = IntlCalendar::fromDateTime ( ’2019-08-29 11: 20: 20’ );  
// Get the time represented by the object $calTime = $calendar2 -> getTime();  
// Show for the first time echo "First Time:" . IntlDateFormatter::formatObject ( $calendar1 ). "" ;  
// Show last time echo "Last Time:" . IntlDateFormatter::formatObject ( $calendar2 ). "" ;  
// Time difference echo "Time difference:" . $calendar1 -> fieldDifference ( $calTime , IntlCalendar::FIELD_YEAR). "- Years" . $calendar1 -> fieldDifference ( $calTime , IntlCalendar::FIELD_MONTH). "- Months" . $calendar1 -> fieldDifference ( $calTime , IntlCalendar::FIELD_DAY_OF_MONTH). "- Days" . $calendar1 -> fieldDifference ( $calTime , IntlCalendar::FIELD_HOUR_OF_DAY). "- Hours" . $calendar1 -> fieldDifference ( $calTime , IntlCalendar::FIELD_MINUTE). "- Minutes" ;  
?>
Exit:
First Time: Dec 21, 2018, 9:30:25 AM Last Time: Aug 29, 2019, 11:20:20 AM Time difference: 0-Years 8-Months 8-Days 1-Hours 49-Minutes
Link: https://www.php.net/manual/en/intlcalendar.fielddifference .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