Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | IntlCalendar getType() Function
Next article icon

PHP | IntlCalendar get() Function

Last Updated : 25 Sep, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The IntlCalendar::get() function is an inbuilt function in PHP which is used to get the value for a specific field.

Syntax:

  • Object oriented style
    int IntlCalendar::get( int $field )
  • Procedural style
    int intlcal_get( IntlCalendar $cal, int $field )

Parameters: This function uses two parameters as mentioned above and described below:

  • $cal: This parameter holds the resource of IntlCalendar.
  • $field: This parameter holds one of the IntlCalendar date/time field constants. This field contains an integer value lies between 0 to IntlCalendar::FIELD_COUNT.

Return Value: This function returns the integer which holds the value of time field.

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

Program:




<?php
  
// Set the DateTime zone
ini_set('date.timezone', 'Asia/Calcutta');
  
// Declare the IntlCalendar class
$cls = new ReflectionClass('IntlCalendar');
  
// Declare an empty array
$arr = array();
  
// Loop for IntlCalendar constants
foreach ($cls->getConstants() as $constName => $constVal) {
    $arr[$constVal] = $constName;
}
  
// Create an instance of IntlCalendar
$calendar = IntlCalendar::createInstance();
  
// Display the date object
var_dump(IntlDateFormatter::formatObject($calendar));
  
// Loop to display result
foreach ($arr as $constVal => $constName) {
    echo "Constant Name: " . $constName . 
    "\nConstant Value: " . $calendar->get($constVal) . "\n\n";
}
  
?>
 
 
Output:
  string(25) "Sep 23, 2019, 11:03:29 AM"  Constant Name: WALLTIME_LAST  Constant Value: 1    Constant Name: WALLTIME_FIRST  Constant Value: 2019    Constant Name: WALLTIME_NEXT_VALID  Constant Value: 8    Constant Name: DOW_TYPE_WEEKEND_CEASE  Constant Value: 39    Constant Name: DOW_WEDNESDAY  Constant Value: 4    Constant Name: DOW_THURSDAY  Constant Value: 23    Constant Name: DOW_FRIDAY  Constant Value: 266    Constant Name: DOW_SATURDAY  Constant Value: 2    Constant Name: FIELD_DAY_OF_WEEK_IN_MONTH  Constant Value: 4    Constant Name: FIELD_AM_PM  Constant Value: 0    Constant Name: FIELD_HOUR  Constant Value: 11    Constant Name: FIELD_HOUR_OF_DAY  Constant Value: 11    Constant Name: FIELD_MINUTE  Constant Value: 3    Constant Name: FIELD_SECOND  Constant Value: 29    Constant Name: FIELD_MILLISECOND  Constant Value: 939    Constant Name: FIELD_ZONE_OFFSET  Constant Value: 19800000    Constant Name: FIELD_DST_OFFSET  Constant Value: 0    Constant Name: FIELD_YEAR_WOY  Constant Value: 2019    Constant Name: FIELD_DOW_LOCAL  Constant Value: 2    Constant Name: FIELD_EXTENDED_YEAR  Constant Value: 2019    Constant Name: FIELD_JULIAN_DAY  Constant Value: 2458750    Constant Name: FIELD_MILLISECONDS_IN_DAY  Constant Value: 39809939    Constant Name: FIELD_IS_LEAP_MONTH  Constant Value: 0    Constant Name: FIELD_FIELD_COUNT  Constant Value:  

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



Next Article
PHP | IntlCalendar getType() Function
author
jit_t
Improve
Article Tags :
  • PHP
  • Web Technologies
  • PHP-function
  • PHP-Intl

Similar Reads

  • PHP | IntlCalendar getTime() Function
    The IntlCalendar::getTime() function is an inbuilt function in PHP which is used to return the time currently represented by the object. The time is expressed in terms of milliseconds since the epoch. Syntax: Object oriented style float IntlCalendar::getTime( void ) Procedural style float intlcal_ge
    1 min read
  • PHP | IntlCalendar getType() Function
    The IntlCalendar::getType() function is an inbuilt function in PHP which is used to get the calendar type in terms of string. The "calendar" is the valid value of keywords. Syntax: Object oriented stylestring IntlCalendar::getType( void )Procedural stylestring intlcal_get_type( IntlCalendar $cal ) P
    1 min read
  • PHP | IntlCalendar getTimeZone() Function
    The IntlCalendar::getTimeZone() function is an inbuilt function in PHP which is used to return the timezone object associated with this calendar. Syntax: Object oriented style IntlTimeZone IntlCalendar::getTimeZone( void ) Procedural style IntlTimeZone intlcal_get_time_zone( IntlCalendar $cal ) Para
    2 min read
  • PHP | IntlCalendar getErrorCode() Function
    The IntlCalendar::getErrorCode() function is an inbuilt function in PHP which returns the numeric ICU error code for the last call on this object or the IntlCalendar given for the calendar parameter. This function can indicate a warning message (negative error code) or no error. Syntax: Object orien
    1 min read
  • PHP | IntlCalendar set() Function
    The IntlCalendar::set() function is an inbuilt function in PHP which is used to set the time field or several common fields at once. The range of field value depends on the calendar. This function can not be called with exactly four parameters. Syntax: Object oriented style bool IntlCalendar::set( i
    2 min read
  • PHP | IntlCalendar add() Function
    The IntlCalendar::add() function is an inbuilt function in PHP which is used to add a signed amount of time to a field. Syntax: Object oriented style: bool IntlCalendar::add( int $field, int $amount ) Procedural style: bool intlcal_add( IntlCalendar $cal, int $field, int $amount ) Parameters: $cal:
    2 min read
  • PHP | IntlCalendar roll() Function
    The IntlCalendar::roll() function is an inbuilt function in PHP which is used to add value to field without carrying into more significant fields. The difference between IntlCalendar::roll() and IntlCalendar::add() function is that, the field value of IntlCalendar::roll() function overflow, it does
    2 min read
  • PHP | IntlCalendar isSet() Function
    The IntlCalendar::isSet() function is an inbuilt function in PHP which is used to check whether a given field is set or not. This function is opposite to IntlCalendar::clear() function. Syntax: Object oriented style bool IntlCalendar::isSet( int $field ) Procedural style bool intlcal_is_set( IntlCal
    1 min read
  • PHP | IntlCalendar getErrorMessage() Function
    The IntlCalendar::getErrorMessage() function is an inbuilt function in PHP which is used to return the error message (if any error exist) associated with the error by using IntlCalendar::getErrorCode() or intlcal_get_error_code() function. Syntax: Object oriented style string IntlCalendar::getErrorM
    1 min read
  • PHP | IntlCalendar after() Function
    The IntlCalendar::after() function is an inbuilt function in PHP which returns True if the object time is after that of the passed object. Syntax: Object oriented style:bool IntlCalendar::after( IntlCalendar $other )Procedural style:bool intlcal_after( IntlCalendar $cal, IntlCalendar $other ) Parame
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences