Function: gmstrftime version 119

Function:
Description: Format a GMT/UCT time/date according to locale settings.
Version:
Status: latest
Date: 2011-12-20 05:31
Summary: Import from phpjs.
Programmer: jj5
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function gmstrftime (format, timestamp) {
    // http://jsphp.co/jsphp/fn/view/gmstrftime
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Alex
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: strftime
    // *     example 1: gmstrftime("%A", 1062462400);
    // *     returns 1: 'Tuesday'
    var dt = ((typeof(timestamp) == 'undefined') ? new Date() : // Not provided
    (typeof(timestamp) == 'object') ? new Date(timestamp) : // Javascript Date()
    new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
    );
    timestamp = Date.parse(dt.toUTCString().slice(0, -4)) / 1000;
    return this.strftime(format, timestamp);
}
[top]

Comments

There are no comments yet, be the first!

Please Login or Register to post comments.