Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date() value source - (JQuery)

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
0
0
US
When an operation is performed on the Date() value in a JavaScript or JQuery routine, where does the value of the Date() come from?

Example: dateutils.convertToDotNetDateInLocalTime(new Date()))

* The individual workstation's OS Date & Time?
* The backend server's OS Date & Time?
* Somewhere else?

The reason I ask is that while a number of users are working just fine, one or more users are posting 'strange' Date/Time values (off by 1 hour and/or off by 25 hours) - even when their individual workstation Date/Time/TimeZone/'Daylight Saving' settings appear correct and are even 'synced' to the Atomic clock.

Thanks,
JRB-Bldr
 
Hi

JavaScript [tt]Date[/tt] objects have no way to access other machines or services. Definitely uses the current machine's system time. Could you post the source of dateutils.convertToDotNetDateInLocalTime() ?

Feherke.
[link feherke.github.com/][/url]
 
Thanks for the reply.

The actual calling code is:
Code:
this.set("DispositionDate", dateutils.convertToDotNetDateInLocalTime(new Date()))

The function's code is:
Code:
dateutils.convertToDotNetDateInLocalTime = function(date){
    try{
        var offsetms = date.getTimezoneOffset() * 60 * 1000;
        date.setTime(date.getTime() - offsetms);
       
        return "/Date(" + date.getTime().toString() + ")/";
    }catch(any){}
    return null;
}

And, after having checked the workstation's Date/Time/TimeZone/'Daylight Saving' settings and found them to appear on the Taskbar as correct and the same in the OS DateTime settings, I cannot figure out how this can be working just fine on the other user's workstations and not on this one individual's workstation.

His OS is Win7, but so are a number of the other users.
I neglected to see if his was 64-bit or 32-bit.
And I neglected to check his DateTime Format setting.

Any ideas/suggestions as to how this can resulting in a wrong value in one place and correct in others?

Thanks,
JRB-Bldr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top