Core Docs | Additional Modules Docs

sb.date.formatter.prototype.format


@Description: used to format the date similar to PHP date
@File: date/formatter.js
@Param: String format The string format of the desired date format
Experiment with it:
m = month as two digit padded string e.g. 03
F = month as full name e.g. July
M = month as full name truncated to three letters e.g. Aug
d = day of month as two digit padded string e.g. 03
l = (lowercase L) day of week as full name e.g. Sunday
D = day as full name truncated to three letters e.g. Sun
Y = full year 4 digit year e.g. 2006
y = 2 digit year e.g. 06
H = hour in 24 hour time e.g. 15
h = hour in standard US format 03
G = hour in 24 hour time wihtout the leading zeros e.g. 9
g = hour in 12 hour time wihtout the leading zeros e.g. 9
a = 'am' or 'pm'
A = 'AM' or 'PM'
i = minutes as two digit padded string e.g. 04
s = seconds as two digit padded string e.g. 04
n = milliseconds e.g. 0-1000
u = UNIX time
@Param: String timestamp A unix timestamp to specify a date other than now
@Example:
//get a formatted date string of the current date/time
    var myDate = new sb.date.formatter();
    //use the format method of the instance to switch date formats
    myDate.format('d/m/y');

sb.date.formatter


@Description: A constructor used to format date strings, based on PHP date function
@File: date/formatter.js
@Param: integer timestamp A unix timestamp to specify a date other than now
@Return: object with the follwoing properties Experiment with it: .m = month as two digit padded string e.g. 03 .F = month as full name e.g. July .M = month as full name truncated to three letters e.g. Aug .d = day of month as two digit padded string e.g. 03 .l = (lowercase L) day of week as full name e.g. Sunday .D = day as full name truncated to three letters e.g. Sun .Y = full year 4 digit year e.g. 2006 .y = 2 digit year e.g. 06 .H = hour in 24 hour time e.g. 15 .h = hour in standard US format 03 .G - hour in 24 hour time minus the zero padding in H .g - hour in standard US format minus the zero padding in h .a - am or pm .A - AM or PM .i = minutes as two digit padded string e.g. 04 .s = seconds as two digit padded string e.g. 04 .n = milliseconds e.g. 0-1000 .u = UNIX time
@Example:
//create a sb.date object of the current date/time
var myDate = new sb.date.formatter();

//create a sb.date object of another date/time by unixtimestamp
var myDate = new sb.date.formatter(1174337641);

//alerts the minute of the date object
alert(myDate.i);

//alerts a formatted date string based on your date object
var myDate = new sb.date.formatter();
alert(myDate.format('/m/d/y H:i:s');