• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

timestamp using javascript

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic