$date is a method to display and format the current date and time.

$date

Display the current date and time, for example, Oct 19, 2003 and 9:54:50 PM respectively.

$date.long

Display the current date and time in a long form, for example, October 19, 2003 and 9:54:50 PM. respectively.

$date.full_date

Display the current date in a full form, for example, Sunday, October 19, 2003.

$date.get('format')

Display the current date in a specific format, for example, $date.get('yyyy-M-d H:m:s') is displayed as 2003-10-19 21:54:50.

LetterDate or Time ComponentExample
GEra designatorAD
yYear 199696
MMonth in yearJuly; Jul; 07
wWeek in year27
WWeek in month2
DDay in year189
dDay in month10
FDay of week in month2
EDay in weekTuesday; Tue
aAm/pm markerPM
HHour in day (0-23)0
kHour in day (1-24)24
KHour in am/pm (0-11)0
hHour in am/pm (1-12)12
mMinute in hour30
sSecond in minute55
SMillisecond978
zTime zonePacific Standard Time; PST; GMT-08.00
ZTime zoneTime zone -0800

Year

  • If the number of letters in a pattern letters is four or more, a calendar specific long form is used.
  • Otherwise, a calendar specific short or abbreviated form is used.
Date and Time PatternResult
yy10
yyyy2010

Month

  • If the number of letters in a pattern is less than 3, the number form is used.
  • If the number of letters in a pattern is 3, a short or abbreviated form is used.
  • If the number of letters in a pattern is 4 or more, the full form is used.
Date and Time PatternResult
M4
MM04
MMMApr
MMMMApril

Days

  • If the number of letters in a pattern is four or more, the full form is used.
  • Otherwise, a calendar specific short or abbreviated form is used.
Date and Time PatternResult
EMon
EEEE