PHP Jddayofweek () Function

PHP

Syntax:
jddayofweek ($jd, $mode)
Parameters:The function takes two parameters as shown above and described below.
  • $jd- it is a required parameter and specifies the Julian day number as an integer. The Gregorian calendar date is converted to a Julian integer using gregoriantojd ($month, $day, $to year).
  • $mode- it is an optional parameter that specifies the type of the return value. It takes a value in the range 0-2 inclusive. The default is 0. The three types of return mode are described below:
    • 0- if the mode is set to 0, it returns 0, 1, 2, 3 & # 8230;, denoting Sunday, Monday, Tuesday & # 8230; respectively as a day of the week. This is the default for the mode when none of the mode parameters are missing or any value is out of range.
    • 1- When mode is passed as 1, it returns Sunday, Monday, Tuesday ...
    • 2- When the mode is set to 2, the abbreviation form MSunday, Monday, Tuesday as Sun, Monday, Tue is returned.
  • 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
    The programs below illustrate the jddayofweek() function Program 1:The program below shows the output when the mode fails and the default mode is selected.
    // PHP demo program
    // using the jddayofweek() function
    // when the second parameter is not passed 
    // converts the date to a Julian integer $jd = gregoriantojd (4, 27, 2018);  
    // prints the day with the specified date echo jddayofweek ( $jd ); ?>
    Output:
    5
    Program 2:The program below shows the output when the mode is 1.
    // PHP demo program
    // using the jddayofweek() function // when mode 1 
    // converts the date to a Julian integer $jd = gregoriantojd (4, 27, 2018) ;  
    // prints the day with the specified date echo jddayofweek ( $jd , 1); ?>
    Output:
    Friday
    Program 3:The program below shows the output when the mode is 2.
    // PHP demo program
    // using the jddayofweek() function // when mode 2 
    // converts the date to a Julian integer $jd = gregoriantojd (4, 27, 2018) ;  
    // prints the day with the specified date echo jddayofweek ( $jd , 2); ?>
    Output:
    Fri
    Program 4:The program below shows the output when the mode is out of range.
    // PHP demo program
    // using the jddayofweek() function // when the mode is out of range 
    // converts the date to a Julian integer $jd = gregoriantojd (4, 27, 2018);  
    // prints the day with the specified date echo jddayofweek ( $jd , 4); ?>
    Output:
    5
    Link:
    http://php.net/manual/ en / function.jddayofweek.php



    Get Solution for free from DataCamp guru