date - date and time
The powerfull date function can generate random dates, and times, that can be displayed in any format suitable for your needs.
The dates and formating rules are based on the javascript lirary Moments.js (check the $format parameter below).
* Unix Epoch = is the time 00:00:00 UTC on 1 January 1970
Usage(s)
date () |
Returns a random date between the Unix Epoch and Now in the ISO-8601 format "YYYY-MM-DD" |
date ( $format ) |
Returns a random date in the $format you provide (range is: Unix Epoch untill $now) |
date ( $format , $dateString ) |
Converts the $dateString to the $format you provide. |
date ( $format , $fromDate , $toDate ) |
Returns a random date in the range from $fromData to $toDate in the $format provided |
Parameter(s)
$dateString |
The ISO-8601 string to be converted |
$fromDate |
The minimum date range to randomly generate dates from. |
$toDate |
The maximum date range to randomly generate dates to. |
$format |
• Moments.js formatting documentation
Token |
Output |
Month |
|
M |
1 2 ... 11 12 |
Mo |
1st 2nd ... 11th 12th |
MM |
01 02 ... 11 12 |
MMM |
Jan Feb ... Nov Dec |
MMMM |
January February ... November December |
Day of Month |
|
D |
1 2 ... 30 30 |
Do |
1st 2nd ... 30th 31st |
DD |
01 02 ... 30 31 |
Day of Year |
|
DDD |
1 2 ... 364 365 |
DDDo |
1st 2nd ... 364th 365th |
DDDD |
001 002 ... 364 365 |
Day of Week |
|
d |
0 1 ... 5 6 |
do |
0th 1st ... 5th 6th |
ddd |
Sun Mon ... Fri Sat |
dddd |
Sunday Monday ... Friday Saturday |
Week of Year |
|
w |
1 2 ... 52 53 |
wo |
1st 2nd ... 52nd 53rd |
ww |
01 02 ... 52 53 |
Year |
|
YY |
70 71 ... 29 30 |
YYYY |
1970 1971 ... 2029 2030 |
AM/PM |
|
A |
AM PM |
a |
am pm |
Hour |
|
H |
0 1 ... 22 23 |
HH |
00 01 ... 22 23 |
h |
1 2 ... 11 12 |
hh |
01 02 ... 11 12 |
Minute |
|
m |
0 1 ... 58 59 |
mm |
00 01 ... 58 59 |
Second |
|
s |
0 1 ... 58 59 |
ss |
00 01 ... 58 59 |
Timezone |
|
z or zz |
EST CST ... MST PST |
Z |
-07:00 -06:00 ... +06:00 +07:00 |
ZZ |
-0700 -0600 ... +0600 +0700 |
Localized date format |
|
LT |
8:30 PM |
L |
07/10/1986 |
LL |
July 10 1986 |
LLL |
July 10 1986 8:30 PM |
LLLL |
Saturday, July 10 1986 8:30 PM |
|
Example(s)
Generating random dates and times in a valid ISO-8601 formatted string
date(YYYY-MM-DDTHH:mm:ss,1979-05-06,2075-09-21)
1980-06-25T21:43:19
2016-10-17T02:44:57
2048-01-17T10:12:41
2005-05-20T21:29:14
2020-01-09T02:48:46
1990-01-28T17:14:26
1983-08-02T01:42:02
2029-09-30T10:03:57
2023-02-25T12:29:18
2038-11-27T14:54:41
2009-10-16T10:35:01
|
Converting a imperial style date in a european date
date(DD/MM/YYYY,2012-12-02)
Will always return 02/12/2012
|
Random dates and times since the Unix Epoch in a custom (European) format
date(DD MMM YYYY H:mm)
13 Aug 1980 19:35
09 Apr 2007 18:15
05 Feb 1998 1:30
05 Jul 2000 19:55
23 Nov 1998 15:22
18 Mar 1995 12:07
20 Sep 1976 15:46
26 Sep 1981 20:39
|
See also
datetime - date and time
time - time