Reputation: 1374
I've just pushed my web application from the production machine (RedHat v5). Cloned it to my development machine (Max OSX 10.10), and my soon to be new server (Redhat v7). And I am getting an error on a line of javascript.
The javascript statement in questions is:
$('#actual_end_date_time').val(date.toString("yyyy-MM-dd HH:mm:ss"));
Alert code to display version and formatted date string:
alert("jqVersion:"+$.fn.jquery+" formatted date:"+date.toString("yyyy-MM-dd HH:mm:ss"));
On the development and productions machines. The string is:
jqVersion:1.3.2 formatted date:2015-02-24 12:29:00
On the soon to be production machine, this string is:
jqVersion:1.3.2 formatted date:Tue Feb 24 2015 12:33:55 GMT-0800 (PST)
As if no formatting is being applied. The code base is identical, the jQuery version that is being used is v1.3.2 (I've tried jQuery v2.1.3, but there are more code failures in the app with that version). In all cases, the web browser was the same: Safari v8.0.3, The web browser's OS is Mac OS X 10.10.2. Later on in the code the data is evaluated by:
Date.parseExact($('#actual_end_date_time').val(),"yyyy-MM-dd HH:mm:ss")'
Giving the console error:
[Error] TypeError: undefined is not a function (evaluating 'Date.parseExact($('#actual_end_date_time').val(),"yyyy-MM-dd HH:mm:ss")')
caldisp_out_2 (index.php, line 769)
onSelect (calendar-setup.js, line 116)
callHandler (calendar.js, line 1281)
cellClick (calendar.js, line 709)
tableMouseUp (calendar.js, line 354)
and then failed (the date object is not stored, and the string may be user entered).
The only difference is the new production machine. It was my impression that javascript ran on the client, and did not care what the server is running.
Any ideas on how I can resolve this?
Upvotes: 0
Views: 3059
Reputation: 1374
My solution was to have the page run the script source date.js again, just before the date formatting was needed. This script is now included twice in the page. I do not know why this was needed just on this one VM server... This placed a band-aid(r) on the problem, but did not solve it.
Upvotes: 0
Reputation: 179
Have you considered using libraries like moment.js to do the formatting for you? Might be the way to get to a consistent look. http://momentjs.com/
Upvotes: 1