PHP Function Reference

PHP jddayofweek() Function



The PHP jddayofweek() function returns the day of the week. This function can return a string or an integer depending on the mode representing the day of the week.

Syntax

jddayofweek(julian_day, mode)

Parameters

julian_day Required. Specify a Julian day number as integer.
mode Optional. Specify the calendar week mode (see table below). Default is 0 - CAL_DOW_DAYNO.

Calendar week modes

ModeValueDescription
CAL_DOW_DAYNO0Return the day number as an int (0=Sunday, 1=Monday, etc)
CAL_DOW_LONG1Returns string containing the day of week (Sunday, Monday, etc.)
CAL_DOW_SHORT2Return a string containing the abbreviated day of week (Sun, Mon, etc.)

Return Value

Returns the Gregorian weekday as either an integer or string.

Exceptions

NA.

Example:

The example below shows the usage of jddayofweek() function.

<?php
//converting a Gregorian date to Julian integer 
$jd = gregoriantojd(10, 2, 2015);
  
//displaying the Julian day integer 
echo "The Julian day integer is: $jd \n";
  
//returning the day of week name as integer
echo "The day of week is: ".jddayofweek($jd)."\n";
?>

The output of the above code will be:

The Julian day integer is: 2457298 
The day of week is: 5

Example:

Consider one more example where other modes are used with this function.

<?php
//converting a Gregorian date to Julian integer 
$jd = gregoriantojd(10, 2, 2015);
  
//displaying the Julian day integer 
echo "The Julian day integer is: $jd \n";
  
//returning the day of week name
echo "The day of week is (mode=0) : ".jddayofweek($jd, 0)."\n";
echo "The day of week is (mode=1) : ".jddayofweek($jd, 1)."\n";
echo "The day of week is (mode=2) : ".jddayofweek($jd, 2)."\n";
?>

The output of the above code will be:

The Julian day integer is: 2457298 
The day of week is (mode=0) : 5
The day of week is (mode=1) : Friday
The day of week is (mode=2) : Fri

❮ PHP Calendar Reference