It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes timestamp using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "timestamp using javascript" Watch "timestamp using javascript" New topic
Author

timestamp using javascript

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
hi how can i get the timestamp of the web page using javascript?i want to know the exact time at which the operation was performed?how should i use javascript for this?

thanx in advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You do not want to use JavaScript to do this since it is using the users time, Are all the clocks in your house correct? My microwave is blinking 12:00. my point is the time may be incorrect, plus you have to deal with timezone issues.

The easiest solution if you are using a Database is to set the column to a default value of the date. Then you do not have to worry. Or just grab the time with a server side language.

Eric
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
You do not want to use JavaScript to do this since it is using the users time, Are all the clocks in your house correct? My microwave is blinking 12:00. my point is the time may be incorrect, plus you have to deal with timezone issues.

The easiest solution if you are using a Database is to set the column to a default value of the date. Then you do not have to worry. Or just grab the time with a server side language.

Thanx Eric
you are absolutly right .
But suppose ignore timezone issues and i just want to have the timestamp for suppose alertbox.i dont want to use serverside language.
using html and javascript i want to find out the timestamp for the any of the functionality eg. alertbox(what time alertbox appeared and what time i clicked ok on it!).
how should i do that?
can u provide some code or example?
thanx again.

swapnil
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Sure you can incorporate the JavaScript time into an alert. I interpreted the question as you were going to save this value on the server.

To get the time in JavaScript you can use

var strTime = new Date().toLocaleString();

Eric
 
 
subject: timestamp using javascript
 
Similar Threads
Current time
Timestamp using rollingfileappender
javamail api and timestamping
Getting Client Information
Hibernate Stale Data