Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • 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 | jdmonthname() Function
Next article icon

PHP | jddayofweek() Function

Last Updated : 05 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

The jddayofweek() function is a built-in function in PHP which returns the given day of the week of a Julian integer passed in the argument. The return value is of three types depending on the mode passed in the function. It returns three types of values which represents the day of the week. If the mode is passed as 0, it returns 0, 1, 2... which denotes Sunday, Monday, Tuesday... It returns Sunday, Monday, Tuesday... when 1 is passed as the mode. When 2 is passed as the mode, it returns the abbreviation Sun, Mon, Tue... as the day of the week. 
 

Syntax:  

jddayofweek($jd, $mode)


Parameters: The function accepts two parameters as shown above and described below.  

  1. $jd - This is a mandatory parameter which specifies the julian day number as integer. The Gregorian calendar date is converted to julian day integer using gregoriantojd($month, $day, $year).
  2. $mode - This is an optional parameter which specifies the type of return value. It accepts value in range 0-2 inclusive. The default value is taken as 0. The three types of mode of return are described below: 
    • 0 - When mode is passed as 0, it returns 0, 1, 2, 3.. denoting Sunday, Monday, Tuesday... respectively as the day of the week. This is the default value of mode when no mode parameter is missing or any value out of range is passed.
    • 1 - When mode is passed as 1, it returns Sunday, Monday, Tuesday...
    • 2 - When mode is passed as 2, it returns the abbreviation form of Sunday, Monday, Tuesday as Sun, Mon, Tues..


Return value: The function returns the day of the week depending on the value of the mode passed in the argument as described above.
Examples:  

Input : $jd = 4/27/2018 ,  mode=0  Output : 5  Input : $jd = 4/27/2018 ,  mode=1  Output : Friday


Below programs illustrate the jddayofweek() function
Program 1: The program below demonstrates the output when mode is not passed and default mode is taken. 

php
<?php // PHP program to demonstrate the // use of jddayofweek() function  // when second parameter is not passed  // converts date to julian integer  $jd=gregoriantojd(4, 27, 2018);  // prints the day on the given date echo jddayofweek($jd); ?> 

Output: 

5


Program 2: The program below demonstrates the output when mode is 1. 

php
<?php // PHP program to demonstrate the // use of jddayofweek() function  // when mode is 1  // converts date to julian integer  $jd=gregoriantojd(4, 27, 2018);  // prints the day on the given date echo jddayofweek($jd, 1); ?> 

Output: 

Friday


Program 3: The program below demonstrates the output when mode is 2. 

php
<?php // PHP program to demonstrate the // use of jddayofweek() function  // when mode is 2  // converts date to julian integer  $jd=gregoriantojd(4, 27, 2018);  // prints the day on the given date echo jddayofweek($jd, 2); ?> 

Output: 

Fri


Program 4: The program below demonstrates the output when mode is out of range. 

php
<?php // PHP program to demonstrate the // use of jddayofweek() function  // when mode is out of range  // converts date to julian integer  $jd=gregoriantojd(4, 27, 2018);  // prints the day on the given date echo jddayofweek($jd, 4); ?> 

Output: 

5


Reference: 
http://php.net/manual/en/function.jddayofweek.php


Next Article
PHP | jdmonthname() Function

G

gopaldave
Improve
Article Tags :
  • Misc
  • Web Technologies
  • PHP
  • PHP-Calendar
Practice Tags :
  • Misc

Similar Reads

    PHP | cal_days_in_month( ) Function
    The cal_days_in_month( ) function in PHP is an inbuilt function which is used to return the number of days in a month for a specific year and according to a specific calendar such as Gregorian calendar, French calendar, Jewish calendar etc. The cal_days_in_month() function takes three parameters whi
    2 min read
    PHP | cal_from_jd() Function
    The cal_from_jd() function is an inbuilt function in PHP that is used to convert a Julian Day Count into a supported calendar such as the Gregorian calendar, French Calendar, Jewish calendar, etc. This function accepts two parameters $jd and $calendar and returns the array containing calendar inform
    2 min read
    PHP | cal_info( ) Function
    The cal_info() function in PHP is an inbuilt function that is used to return information about a specified calendar. The cal_info() function returns an array that contains the calname, month, abbrevmonth and maxdaysinmonth, and calsymbol. It takes the calendar as a parameter and returns the informat
    2 min read
    PHP | cal_to_jd() Function
    The cal_to_jd() function is an inbuilt function in PHP which is used to converts a specified date into Julian Day Count. The cal_to_jd() function calculates the Julian day count for a date in the specified calendar. This function supports CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH calendar
    2 min read
    PHP | easter_date() Function
    The easter_date() function is a built-in function in PHP which returns the Easter date in the year passed as an argument. The current year is taken as default year when no arguments are passed as parameter. Syntax: easter_date( $year ) Parameter: The function accepts one optional parameter $year whi
    2 min read
    PHP | easter_days() Function
    The easter_days() Function is a built-in function in PHP which returns the number of days after March 21, that the Easter Day is in the given year. When no year is given, the current year is taken as the default value. Syntax: easter_days( $year, $method ) Parameters: The function accepts two option
    2 min read
    PHP | frenchtojd() Function
    The frenchtojd() function is a built-in function which converts a French date to a Julian Day Count. The function accepts three parameters in format $month / $day / $year, which represents the date in French republican calendar and converts it to a Julian Day count. Syntax: frenchtojd( $month, $day,
    2 min read
    PHP | gregoriantojd() Function
    The gregoriantojd() function is a built-in function which converts a Gregorian date to a Julian Day Count. The function accepts three parameters in format $month / $day / $year, which represents the date in Gregorian calendar and converts it to a Julian Day count. Syntax: gregoriantojd( $month, $day
    2 min read
    PHP | jddayofweek() Function
    The jddayofweek() function is a built-in function in PHP which returns the given day of the week of a Julian integer passed in the argument. The return value is of three types depending on the mode passed in the function. It returns three types of values which represents the day of the week. If the
    3 min read
    PHP | jdmonthname() Function
    The jdmonthname() function is a built-in function in PHP which returns the month name of a Julian day number passed as the argument. The return value is of six types depending on the mode passed in the function which is explained briefly below in the parameter part. Syntax: jdmonthname($jd, $mode) P
    4 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