Function: date_default_timezone_set version 113

Function:
Description: Sets the default timezone used by all date/time functions in a script.
Version:
Status: latest
Date: 2011-12-20 05:27
Summary: Import from phpjs.
Programmer: jj5
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function date_default_timezone_set (tz) {
    // http://jsphp.co/jsphp/fn/view/date_default_timezone_set
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: timezone_abbreviations_list
    // %        note 1: Uses global: php_js to store the default timezone
    // *     example 1: date_default_timezone_set('unknown');
    // *     returns 1: 'unknown'
    var tal = {},
        abbr = '',
        i = 0;

    // BEGIN REDUNDANT
    this.php_js = this.php_js || {};
    // END REDUNDANT
    // PHP verifies that the timezone is valid and also sets this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST if so
    tal = this.timezone_abbreviations_list();
    for (abbr in tal) {
        for (i = 0; i < tal[abbr].length; i++) {
            if (tal[abbr][i].timezone_id === tz) {
                this.php_js.default_timezone = tz;
                return true;
            }
        }
    }
    return false;
}
[top]

Comments

There are no comments yet, be the first!

Please Login or Register to post comments.