Date

Format your dates easily.

Functions

Util.date

Definition

Name
Util.date
Syntax
String = Util.date( String format [, Mixed timestamp [, Array months] ]);

Description

Format UNIX timestamp or reformat datetime string.

Parameters

format
String date/time format
Options
d
Day of the month, 2 digits with leading zeros: 01 to 31
j
Day of the month without leading zeros: 1 to 31
m
Numeric representation of a month, with leading zeros: 01 through 12
n
Numeric representation of a month, without leading zeros: 1 through 12
F
Full month string, given as array
Y
Full numeric representation of a year, 4 digits
G
24-hour format of an hour without leading zeros: 0 through 23
H
24-hour format of an hour with leading zeros 00 through 23
i
Minutes with leading zeros 00 to 59
s
Seconds, with leading zeros 00 through 59
timestamp
String/Number Optional, unix timestamp in milliseconds since 1970 or valid Date-string. If timestamp is omitted, current time is used.
months
Array Optional, Array with months. If months is omitted, the "F"-character cannot be used.

Return values

String Formatted datetime string.

Examples

u.date("Y-m-d H:i:s");

returns

u.date("Y-m-d", 1331809993423);

returns

u.date("Y-m-d", "Mon Mar 12 2012 12:13:36 GMT+0100 (CET)");

returns

u.date("j/n", "Sat Mar 10 17:58:43 +0000 2012");

returns

u.date("F d, Y", false, ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]);

returns

Dependencies

JavaScript
  • String.match
  • String.replace
  • Array.slice
  • Date
Manipulator

Nothing

Files

Main file

  • u-date.js

Segment support files

  • none

Segment dependencies

desktop_edge
u-date.js
desktop_ie11
u-date.js
desktop
u-date.js
desktop_ie10
u-date.js
desktop_ie9
u-date.js
desktop_light
u-date.js
tablet
u-date.js
tablet_light
u-date.js
smartphone
u-date.js
mobile
not tested
mobile_light
not tested
tv
u-date.js
seo
not supported