...

View Full Version : get Date



Laurence485
12-26-2011, 09:54 PM
Hi,
i need to get the current date into some format so that it doesn't change?
here i have some code:

function printTime(){
var d=new Date();
var utc = d.toUTCString();
alert(utc);
}

for example this show for me: Mon, 26 Dec 2011 21:55:43 GMT

I would like to get this information again, lets say 5 minutes later - but i want the information to still read Mon, 26 Dec 2011 21:55:43 GMT not Mon, 26 Dec 2011 22:00:43 GMT for example

Any help greatly appreciated

jmrker
12-26-2011, 11:12 PM
Hi,
i need to get the current date into some format so that it doesn't change?
here i have some code:

function printTime(){
var d=new Date();
var utc = d.toUTCString();
alert(utc);
}

for example this show for me: Mon, 26 Dec 2011 21:55:43 GMT

I would like to get this information again, lets say 5 minutes later - but i want the information to still read Mon, 26 Dec 2011 21:55:43 GMT not Mon, 26 Dec 2011 22:00:43 GMT for example

Any help greatly appreciated

I don't understand your request...:confused:

You want to display the same date, but not the same time?
And you want the time to be earlier than before after a 5 minute delay?

If that is what you want, form you date display to a global variable.
Then display it as many times as you want anywhere you want.
Until you change the variable, it will display the same thing each time!

Laurence485
12-26-2011, 11:25 PM
I don't understand your request...:confused:

You want to display the same date, but not the same time?
And you want the time to be earlier than before after a 5 minute delay?

If that is what you want, form you date display to a global variable.
Then display it as many times as you want anywhere you want.
Until you change the variable, it will display the same thing each time!

hi i want to display the same date and the same time i.e. no matter how many times i call alert(utc) it will always show exactly the same date and same time.

function printTime(){
var d=new Date();
var utc = d.toUTCString();
alert(utc);
alert(utc);
alert(utc);
}
i want utc to be the same value each time it is called. So for example:
Mon, 26 Dec 2011 21:55:43 GMT
Mon, 26 Dec 2011 21:55:43 GMT
Mon, 26 Dec 2011 21:55:43 GMT

jmrker
12-26-2011, 11:54 PM
Still see little use for it, but here your go...


<!DOC HTML>
<html>
<head>
<title> Untitled </title>
<script type="text/javascript">
var utc = new Date().toUTCString();
function printTime(){
alert(utc);
alert(utc);
alert(utc);
}
</script>

</head>
<body>
<button onclick="printTime()">Print time</button>
<button onclick="printTime()">Print time again!</button>
<button onclick="printTime()">One more time</button>
</body>
</html>

Laurence485
12-27-2011, 12:33 AM
Still see little use for it, but here your go...


<!DOC HTML>
<html>
<head>
<title> Untitled </title>
<script type="text/javascript">
var utc = new Date().toUTCString();
function printTime(){
alert(utc);
alert(utc);
alert(utc);
}
</script>

</head>
<body>
<button onclick="printTime()">Print time</button>
<button onclick="printTime()">Print time again!</button>
<button onclick="printTime()">One more time</button>
</body>
</html>


modified your code a bit to get it for what i required. The purpose for it is to let the user know what time they started using an application.
thanks for your help

jmrker
12-27-2011, 01:59 AM
modified your code a bit to get it for what i required. The purpose for it is to let the user know what time they started using an application.
thanks for your help

You're most welcome.
Happy to help.

I find most would use it to determine how long the user had been on page.
That would be determined by subtracting the start time from the current time.
But, if that's they way you wish it to be displayed, Good Luck!
;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum