» Javascript equivalent for PHP's date
399 PHP equivalents
- PHP.JS Licensing
- PHP.JS SVN
- PHP.JS Namespaced
- abs
- acosh
- acos
- addslashes
- aggregate
- aggregate_info
- aggregate_methods
- aggregate_methods_by_list
- aggregate_methods_by_regexp
- aggregate_properties
- aggregate_properties_by_list
- aggregate_properties_by_regexp
- aggregation_info
- array
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff
- array_diff_assoc
- array_diff_key
- array_diff_uassoc
- array_diff_ukey
- array_fill
- array_fill_keys
- array_filter
- array_flip
- array_intersect
- array_intersect_assoc
- array_intersect_key
- array_intersect_uassoc
- array_intersect_ukey
- array_keys
- array_key_exists
- array_map
- array_merge
- array_merge_recursive
- array_multisort
- array_pad
- array_pop
- array_product
- array_push
- array_rand
- array_reduce
- array_reverse
- array_search
- array_shift
- array_slice
- array_splice
- array_sum
- array_udiff
- array_udiff_assoc
- array_udiff_uassoc
- array_uintersect
- array_uintersect_assoc
- array_uintersect_uassoc
- array_unique
- array_unshift
- array_values
- array_walk
- array_walk_recursive
- arsort
- asinh
- asin
- asort
- assert
- assert_options
- atan2
- atanh
- atan
- base64_decode
- base64_encode
- basename
- base_convert
- bin2hex
- bindec
- call_user_func
- call_user_func_array
- ceil
- checkdate
- chop
- chr
- chunk_split
- classkit_import
- classkit_method_add
- classkit_method_copy
- classkit_method_redefine
- classkit_method_remove
- classkit_method_rename
- class_exists
- compact
- constant
- convert_uuencode
- cosh
- cos
- count
- count_chars
- crc32
- create_function
- ctype_alnum
- ctype_alpha
- ctype_cntrl
- ctype_digit
- ctype_graph
- ctype_lower
- ctype_print
- ctype_punct
- ctype_space
- ctype_upper
- ctype_xdigit
- current
- » date
- date_default_timezone_get
- date_default_timezone_set
- date_parse
- deaggregate
- decbin
- dechex
- decoct
- defined
- define
- deg2rad
- die
- dirname
- doubleval
- each
- echo
- empty
- end
- exit
- explode
- expm1
- exp
- extract
- fclose
- feof
- fgetcsv
- fgetc
- fgetss
- fgets
- filemtime
- filesize
- file
- file_exists
- file_get_contents
- floatval
- floor
- fmod
- fopen
- fpassthru
- fread
- fseek
- ftell
- function_exists
- func_get_args
- func_get_arg
- func_num_args
- getdate
- getenv
- getlastmod
- getrandmax
- gettimeofday
- gettype
- get_cfg_var
- get_class
- get_class_methods
- get_class_vars
- get_declared_classes
- get_defined_constants
- get_defined_functions
- get_defined_vars
- get_headers
- get_html_translation_table
- get_included_files
- get_meta_tags
- get_object_vars
- get_required_files
- get_resource_type
- gmdate
- gmmktime
- gmstrftime
- gopher_parsedir
- hexdec
- htmlentities
- htmlspecialchars
- htmlspecialchars_decode
- html_entity_decode
- http_build_query
- hypot
- idate
- implode
- import_request_variables
- include
- include_once
- ini_alter
- ini_get
- ini_get_all
- ini_restore
- ini_set
- intval
- in_array
- ip2long
- isset
- is_array
- is_binary
- is_bool
- is_buffer
- is_callable
- is_double
- is_finite
- is_float
- is_infinite
- is_integer
- is_int
- is_long
- is_nan
- is_null
- is_numeric
- is_object
- is_real
- is_resource
- is_scalar
- is_string
- is_unicode
- join
- json_decode
- json_encode
- key
- krsort
- ksort
- lcfirst
- lcg_value
- levenshtein
- localeconv
- localtime
- log10
- log1p
- log
- long2ip
- ltrim
- max
- md5
- md5_file
- method_exists
- microtime
- min
- mktime
- mt_getrandmax
- mt_rand
- natcasesort
- natsort
- next
- nl2br
- nl_langinfo
- number_format
- octdec
- ord
- parse_str
- parse_url
- pathinfo
- pclose
- phpversion
- php_ini_loaded_file
- php_ini_scanned_files
- php_strip_whitespace
- pi
- popen
- pos
- pow
- preg_grep
- preg_quote
- prev
- printf
- print_r
- property_exists
- putenv
- quoted_printable_decode
- quoted_printable_encode
- quotemeta
- rad2deg
- rand
- range
- rawurldecode
- rawurlencode
- readfile
- realpath
- register_shutdown_function
- require
- require_once
- reset
- restore_exception_handler
- rewind
- round
- rsort
- rtrim
- runkit_class_adopt
- runkit_class_emancipate
- runkit_function_add
- runkit_function_copy
- runkit_function_redefine
- runkit_function_remove
- runkit_function_rename
- runkit_import
- runkit_method_add
- runkit_method_copy
- runkit_method_redefine
- runkit_method_remove
- runkit_method_rename
- runkit_superglobals
- serialize
- setcookie
- setlocale
- setrawcookie
- settype
- set_exception_handler
- set_time_limit
- sha1
- sha1_file
- shuffle
- sinh
- sin
- sizeof
- sleep
- sort
- soundex
- split
- sprintf
- sql_regcase
- sqrt
- strcasecmp
- strchr
- strcmp
- strcoll
- strcspn
- strftime
- stripos
- stripslashes
- strip_tags
- stristr
- strlen
- strnatcasecmp
- strnatcmp
- strncasecmp
- strncmp
- strpbrk
- strpos
- strrchr
- strrev
- strripos
- strrpos
- strspn
- strstr
- strtok
- strtolower
- strtotime
- strtoupper
- strtr
- strval
- str_getcsv
- str_ireplace
- str_pad
- str_repeat
- str_replace
- str_rot13
- str_shuffle
- str_split
- str_word_count
- substr
- substr_compare
- substr_count
- substr_replace
- tanh
- tan
- timezone_abbreviations_list
- timezone_identifiers_list
- time
- time_nanosleep
- time_sleep_until
- trim
- uasort
- ucfirst
- ucwords
- uksort
- uniqid
- unserialize
- urldecode
- urlencode
- usleep
- usort
- utf8_decode
- utf8_encode
- var_dump
- var_export
- vprintf
- vsprintf
- wordwrap
PHP to Javascript Project: php.js
This article is part of the 'Porting PHP to Javascript' Project, which aims to decrease the gap between developing for PHP & Javascript.
A lot of people are familiar with PHP's functions, and though Javascript functions are often quite similar, some functions may be missing or addressed differently. The Javascript implementations should be as compliant with the PHP versions as possible, a good indication is that the PHP function manual could also apply to the Javascript version.
Porting crucial PHP functions to Javascript can be fun & useful. Currently some PHP functions have been added, but readers are encouraged to contribute and improve functions by adding comments. Eventually the goal is to save all the functions in one php.js file and make it publicly available for your coding pleasure.
If you choose to contribute, let me know how you want to be credited in the function's comments. You may also want to subscribe to RSS so you receive updates whenever new functions are posted.
This is a Javascript version of the PHP function: date.
I have moved out PHP.JS to it's own site. For info & reactions on comments please goto phpjs.org
PHP date
Description
date - Format a local time/date
string date( string format [, int timestamp] )
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.In other words, timestamp is optional and defaults to the value of time().
Parameters
-
format
The format of the outputted date string. See the formatting options below.
The following characters are recognized in the format parameter string
format character Description Example returned values Day --- --- d Day of the month, 2 digits with leading zeros 01 to 31 D A textual representation of a day, three letters Mon through Sun j Day of the month without leading zeros 1 to 31 l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday) S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) z The day of the year (starting from 0) 0 through 365 Week --- --- W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year) Month --- --- F A full textual representation of a month, such as January or March January through December m Numeric representation of a month, with leading zeros 01 through 12 M A short textual representation of a month, three letters Jan through Dec n Numeric representation of a month, without leading zeros 1 through 12 t Number of days in the given month 28 through 31 Year --- --- L Whether it's a leap year 1 if it is a leap year, 0 otherwise. o ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) Examples: 1999 or 2003 Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003 y A two digit representation of a year Examples: 99 or 03 Time --- --- a Lowercase Ante meridiem and Post meridiem am or pm A Uppercase Ante meridiem and Post meridiem AM or PM B Swatch Internet time 000 through 999 g 12-hour format of an hour without leading zeros 1 through 12 G 24-hour format of an hour without leading zeros 0 through 23 h 12-hour format of an hour with leading zeros 01 through 12 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 u Milliseconds (added in PHP 5.2.2) Example: 54321 Timezone --- --- e Timezone identifier (added in PHP 5.1.0) Examples: UTC, GMT, Atlantic/Azores I (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise. O Difference to Greenwich time (GMT) in hours Example: +0200 P Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00 T Timezone abbreviation Examples: EST, MDT ... Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 50400 Full Date/Time --- --- c ISO 8601 date (added in PHP 5) 2004-02-12T15:19:21+00:00 r » RFC 2822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200 U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) See also time() Unrecognized characters in the format string will be printed as-is. The Z format will always return 0 when using gmdate().
Note: Since this function only accepts integer timestamps the u format character is only useful when using the date_format() function with user based timestamps created with date_create().
-
timestamp
The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
Return Values
Returns a formatted date string. If a non-numeric value is used for timestamp , FALSE is returned and an E_WARNING level error is emitted.
See Also
- javascript getlastmod()
- javascript gmdate()
- javascript mktime()
- javascript strftime()
- javascript time()
Javascript date
Source
This is the main source of the Javascript version of PHP's date
function date ( format, timestamp ) { // http://kevin.vanzonneveld.net // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) // + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: MeEtc (http://yass.meetcweb.com) // + improved by: Brad Touesnard // + improved by: Tim Wiel // + improved by: Bryan Elliott // + improved by: Brett Zamir (http://brett-zamir.me) // + improved by: David Randall // + input by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Brett Zamir (http://brett-zamir.me) // + improved by: Brett Zamir (http://brett-zamir.me) // + derived from: gettimeofday // % note 1: Uses global: php_js to store the default timezone // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400); // * returns 1: '09:09:40 m is month' // * example 2: date('F j, Y, g:i a', 1062462400); // * returns 2: 'September 2, 2003, 2:26 am' // * example 3: date('Y W o', 1062462400); // * returns 3: '2003 36 2003' // * example 4: x = date('Y m d', (new Date()).getTime()/1000); // 2009 01 09 // * example 4: (x+'').length == 10 // * returns 4: true var jsdate=( (typeof(timestamp) == 'undefined') ? new Date() : // Not provided (typeof(timestamp) == 'number') ? new Date(timestamp*1000) : // UNIX timestamp new Date(timestamp) // Javascript Date() ); // , tal=[] var pad = function(n, c){ if( (n = n + "").length < c ) { return new Array(++c - n.length).join("0") + n; } else { return n; } }; var _dst = function (t) { // Calculate Daylight Saving Time (derived from gettimeofday() code) var dst=0; var jan1 = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0); // jan 1st var june1 = new Date(t.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st var temp = jan1.toUTCString(); var jan2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1)); temp = june1.toUTCString(); var june2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1)); var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60); if (std_time_offset === daylight_time_offset) { dst = 0; // daylight savings time is NOT observed } else { // positive is southern, negative is northern hemisphere var hemisphere = std_time_offset - daylight_time_offset; if (hemisphere >= 0) { std_time_offset = daylight_time_offset; } dst = 1; // daylight savings time is observed } return dst; }; var ret = ''; var txt_weekdays = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"]; var txt_ordin = {1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"}; var txt_months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var f = { // Day d: function(){ return pad(f.j(), 2); }, D: function(){ var t = f.l(); return t.substr(0,3); }, j: function(){ return jsdate.getDate(); }, l: function(){ return txt_weekdays[f.w()]; }, N: function(){ return f.w() + 1; }, S: function(){ return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th'; }, w: function(){ return jsdate.getDay(); }, z: function(){ return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) / 864e5 >> 0; }, // Week W: function(){ var a = f.z(), b = 364 + f.L() - a; var nd2, nd = (new Date(jsdate.getFullYear() + "/1/1").getDay() || 7) - 1; if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){ return 1; } if(a <= 2 && nd >= 4 && a >= (6 - nd)){ nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31"); return date("W", Math.round(nd2.getTime()/1000)); } return (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 0); }, // Month F: function(){ return txt_months[f.n()]; }, m: function(){ return pad(f.n(), 2); }, M: function(){ var t = f.F(); return t.substr(0,3); }, n: function(){ return jsdate.getMonth() + 1; }, t: function(){ var n; if( (n = jsdate.getMonth() + 1) == 2 ){ return 28 + f.L(); } if( n & 1 && n < 8 || !(n & 1) && n > 7 ){ return 31; } return 30; }, // Year L: function(){ var y = f.Y(); return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0; }, o: function(){ if (f.n() === 12 && f.W() === 1) { return jsdate.getFullYear()+1; } if (f.n() === 1 && f.W() >= 52) { return jsdate.getFullYear()-1; } return jsdate.getFullYear(); }, Y: function(){ return jsdate.getFullYear(); }, y: function(){ return (jsdate.getFullYear() + "").slice(2); }, // Time a: function(){ return jsdate.getHours() > 11 ? "pm" : "am"; }, A: function(){ return f.a().toUpperCase(); }, B: function(){ // peter paul koch: var off = (jsdate.getTimezoneOffset() + 60)*60; var theSeconds = (jsdate.getHours() * 3600) + (jsdate.getMinutes() * 60) + jsdate.getSeconds() + off; var beat = Math.floor(theSeconds/86.4); if (beat > 1000) { beat -= 1000; } if (beat < 0) { beat += 1000; } if ((String(beat)).length == 1) { beat = "00"+beat; } if ((String(beat)).length == 2) { beat = "0"+beat; } return beat; }, g: function(){ return jsdate.getHours() % 12 || 12; }, G: function(){ return jsdate.getHours(); }, h: function(){ return pad(f.g(), 2); }, H: function(){ return pad(jsdate.getHours(), 2); }, i: function(){ return pad(jsdate.getMinutes(), 2); }, s: function(){ return pad(jsdate.getSeconds(), 2); }, u: function(){ return pad(jsdate.getMilliseconds()*1000, 6); }, // Timezone e: function () { /* var abbr='', i=0; if (this.php_js && this.php_js.default_timezone) { return this.php_js.default_timezone; } if (!tal.length) { tal = timezone_abbreviations_list(); } for (abbr in tal) { for (i=0; i < tal[abbr].length; i++) { if (tal[abbr][i].offset === -jsdate.getTimezoneOffset()*60) { return tal[abbr][i].timezone_id; } } } */ return 'UTC'; }, I: function(){ return _dst(jsdate); }, O: function(){ var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4); t = (jsdate.getTimezoneOffset() > 0) ? "-"+t : "+"+t; return t; }, P: function(){ var O = f.O(); return (O.substr(0, 3) + ":" + O.substr(3, 2)); }, T: function () { /* var abbr='', i=0; if (!tal.length) { tal = timezone_abbreviations_list(); } if (this.php_js && this.php_js.default_timezone) { for (abbr in tal) { for (i=0; i < tal[abbr].length; i++) { if (tal[abbr][i].timezone_id === this.php_js.default_timezone) { return abbr.toUpperCase(); } } } } for (abbr in tal) { for (i=0; i < tal[abbr].length; i++) { if (tal[abbr][i].offset === -jsdate.getTimezoneOffset()*60) { return abbr.toUpperCase(); } } } */ return 'UTC'; }, Z: function(){ return -jsdate.getTimezoneOffset()*60; }, // Full Date/Time c: function(){ return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" + f.i() + ":" + f.s() + f.P(); }, r: function(){ return f.D()+', '+f.d()+' '+f.M()+' '+f.Y()+' '+f.H()+':'+f.i()+':'+f.s()+' '+f.O(); }, U: function(){ return Math.round(jsdate.getTime()/1000); } }; return format.replace(/[\\]?([a-zA-Z])/g, function(t, s){ if( t!=s ){ // escaped ret = s; } else if( f[s] ){ // a date function exists ret = f[s](); } else{ // nothing special ret = s; } return ret; }); }
Examples
Currently there are 4 examples
Example 1
date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);And that would return
'09:09:40 m is month'Example 2
date('F j, Y, g:i a', 1062462400);And that would return
'September 2, 2003, 2:26 am'Example 3
date('Y W o', 1062462400);And that would return
'2003 36 2003'More about this Project
Download php.js
To easily include it in your code, every function currently available is stored in
Normal
- uncompressed source: php.js
- minified: php.min.js [recommended]
- compressed: php.packed.js
Namespaced What is 'namespaced?'
- uncompressed source: php.namespaced.js
- minified: php.namespaced.min.js
- compressed: php.namespaced.packed.js
To download use Right click, Save Link As
Generally the best way is to use a minified version and gzip it
Credits
Respect & awards go to everybody who has contributed in some way so far:
Your name here?
Contributing is as easy as adding a comment with better code, or code for a new function.
Any contribution leading to improvement will directly get your name & link here.
Coming Project features
Project features that we are currently working on:
- Done - Site. A place for php.js of it's own. See: phpjs.org.
- Done - Compile. Compile your own php.js version, with only the functions you need. Should generate a hash with which you can retrieve latest versions of your php.js combination. Done - Testsuite. A better test-suite that can be ran locally so developers can easily test before commiting. Also the testing itself should be more thorough.
- Done - Versioning. Individual functions are versioned, but the entire library should be versioned as well.
Stay up to date
You can track my blog
articles and
comments. You may also find my
bookmarks interesting. Or
Follow me on Twitter
Like this article?
|
Then Dzone it! Or use another bookmark button below to show your support & help me spread the word. |
RelatedArticles like this one» PHP.JS Licensing |
tags: programming, php, javascript
category: Programming - Javascript - PHP equivalents
read: 12,480 times
Add Comment
PHP.JS is outgroing this blog and moving to it's own space. Please leave your comment here: http://phpjs.org/functions/date










tagcloud

#32. Kevin on 13 January 2009
#31. David Randall on 10 January 2009
The third line doesn’t produce the correct value because date() is expecting an integer as the 2nd argument. To make this easier for Javascript dates, I suggest changing the following
to
#30. Kevin on 07 January 2009
#29. Brett Zamir on 07 January 2009
#28. Brett Zamir on 07 January 2009
#27. Brett Zamir on 07 January 2009
Now, it looks like we only have the timezone identifiers, 'e' and 'T' left to do.
#26. Brett Zamir on 07 January 2009
Thanks for the idea to check the source code. It gave this one away...
#25. Brett Zamir on 07 January 2009
Note also that your chart should change the description of 'u' from "milliseconds" to "microseconds" per the current PHP documentation for date().
#24. Kevin on 06 January 2009
#23. Bryan Elliott on 06 January 2009
#22. Kevin on 22 May 2008
#21. Bob on 21 May 2008
#20. Kevin on 11 April 2008
#19. Tim Wiel on 11 April 2008
Calling
doesn't return todays date in Mozilla Firefox 2.0.13 on Ubuntu LinuxTo fix it I changed the line reading
to read
#18. Michael White on 06 March 2008
#17. Kevin on 05 March 2008
#16. Michael White on 05 March 2008
For our purposes: UTC = GMT && GMT = UTC // They never differ by more than 0.9 seconds
... [more]
If the epoch was set in UTC time then UTC +1 = CET (your time zone). That means that 00000 seconds in UTC time is equal to 03600 seconds in CET time.
That also means that 00000 seconds in UTC time is equal to -18000 seconds in EST (my time zone).
The final result is that any given point in UNIX epoch time is exactly 21600 seconds different between our time zones (6 hours) which will yield a different date for the same epoch second depending on your time zone.
Layman's terms: UNIX epoch uses UTC zone as "home". If you "travel" outside that zone then you have to take that difference into account. When it was midnight January 1st, 1970 in the UTC zone it was still December 31st here in my time zone. Therefore the "0" second of the UNIX epoch will represent the date Dec. 31, 1969 for EST and will read correctly for you since it was already Jan. 1st 1970 in CET when the unix epoch was set.
I think that out of those explanations you should find one that makes sense to you.
#15. Kevin on 05 March 2008
#14. Michael White on 05 March 2008
In the first paragraph on that page it says that the epoch is "the number of seconds elapsed since midnight Coordinated Universal Time(UTC) of January 1, 1970, not counting leap seconds" which means that the epoch is in fact a single, non-relative point in time rather than a point in time relative to the time zones (since UTC time is always UTC time even if you are in Australia). I think the definition is a hundred percent more clear than my jumbled explanation of it! haha
#13. Michael White on 05 March 2008
#12. Kevin on 04 March 2008
@ Brad Touesnard: Thanks alot I will process your fix tomorrow!
#11. Brad Touesnard on 04 March 2008
Great project, keep it up!
#10. Michael White on 04 March 2008
#9. Kevin on 03 March 2008
So that seems to be the 6 hours difference we're experiencing! I had never realized that this would have impact on UNIX epoch. Apparently it does :(
#8. Michael White on 03 March 2008
My Time Zone is GMT -5 (Eastern Standard Time) I live in Atlanta, Georgia (United States of course). What's your timezone? I noticed it was quite a bit different from mine because I posted a comment around 8 PM on March 2nd and it posted as March 3rd.
Ah! Actually, I have an idea. When I get a chance I am going to calculate the difference between your timezone and mine in seconds since the epoch. Then we can check that difference against the difference we get out of this function to make sure it is just a timezone difference and not a bug.
#7. Kevin on 02 March 2008
This boggles me, could it have anything to do with timezones & locales?
#6. Michael White on 02 March 2008
The one hosted on the shared host is here:
http://sprinkit.net/aether/test.php
That is the exact code I used to duplicate your test.php page. I assume it is identical as far as process.
Anyway - I noticed these on the php.js test page because they turned red when I ran them. The whole page fails to run in IE 7, IE 6, and Safari 3; it just hangs. It runs in Opera 9 and FF2 (win & mac) and in all three browser where it works I get red box with the output matching that of my PHP test page. When I ran my own tests while creating the namespaced version I found that IE 7, IE 6, and Safari 3 also produce the same output (matching my PHP test page).
#5. Kevin on 02 March 2008
http://kevin.vanzonneveld.net/test.php
#4. Michael White on 02 March 2008
The new examples are:
http://crestidg.com
#3. Kevin on 12 February 2008
#2. Kevin on 12 February 2008
#1. Adam on 12 February 2008
The first problem I encountered was that when using either F or M for a month, The function will show the month in advance. m still shows the correct numerical value however. The reason this happens is that the array created with the constants for the months is zero-based. Adding an empty sting before "January" fixes this.
Next problem was that P was giving me an error
Line 197 is "var O = jsdate.O();" within the function for P. First, jsdate.O() should be f.O(). Then comes the problem that the function O does not output the correct output. I have re-written the function for O so it produces the correct output:
Finally, the function U is missing the return keyword.
Cheers,
Adam