So, I have stored dates in my SQL database using GETUTCDATE() which appears to be working fine.
I then created a function that basically gets the JavaScript milliseconds for any date I store. This was simply for doing sorting and filtering.
So, when I create a new Date() object in JavaScript using my milliseconds and call the toLocaleString() function, I get something like:
Tue Oct 30 2012 01:37:57 GMT+0000 (GMT STANDARD TIME)
now, what I would like is this.
I want it to show something like :
Tue Oct 30 2012 01:37:57
and if the person viewing my site has their regional settings set to GMT + 0200 I want the time to be displayed for them in their region:
Tue Oct 30 2012 03:37:57
I have been searching for ages and I just can't find anything to do it.
I thought that date.js would work, but it can't handle the "(GMT STANDARD TIME)" which is a shame.
anyway,
Any help would be greatly appreciated.
/r3plica
10-31-2012, 09:10 AM
JMRKER
I'm not sure I understand your problem. :confused:
When I run the following script, I get exactly what you want...
Code:
<!DOCTYPE HTML>
<html>
<head>
<title> Untitled </title>
<script type="text/javascript">
var now = new Date();
alert(now.toLocaleString());
</script>
</head>
<body>
</body>
</html>
The time displays for my own time zone without any adjustments.
Do you have an example that shows the error you are getting?
Is you browser set-up to show something different?