473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

getting date/time from javascript

I have a page where I need to display the unix time (seconds) upon
page load. I've found many complex examples that auto update, count
live, etc., but I need to just display the time at the time of page
load. I think it has something to do with getTime, showDate, or maybe
loadTime, but I can't quite seem to get the syntax.
Could someone provide the exact syntax and usage within the html to
make this work?

Thanks!

Oct 26 '07 #1
2 2878
wrote on 26 okt 2007 in comp.lang.javascript:
I have a page where I need to display the unix time (seconds) upon
page load. I've found many complex examples that auto update, count
live, etc., but I need to just display the time at the time of page
load. I think it has something to do with getTime, showDate, or maybe
loadTime, but I can't quite seem to get the syntax.
Since "unix time" has different flavours, let me give you this:

var milisecs = +new Date();

gives you the exact number of miliseconds since

var start = new Date(0); // 1 jan 1970 00:00:00:000 UTC

on the local machine.
Could someone provide the exact syntax and usage within the html to
make this work?
So you are not inclined to do some programming yourself?

It seems you need a paid programmer.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 26 '07 #2
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Fri, 26 Oct 2007 17:53:42, Evertjan. <ex**************@interxnl.net>
posted:
>
var milisecs = +new Date();

gives you the exact number of miliseconds since

var start = new Date(0); // 1 jan 1970 00:00:00:000 UTC

on the local machine.
Strictly, not quite exactly.

The number of milliseconds is incremented at an interval which may
average 54.9, 15.625, 10, or other number of milliseconds. Sometimes,
that matters.

And it's the number of milliseconds UT or GMT; UTC has Leap Seconds too.

Using (new Date()/1000)|0 will do for a bit over 30 years

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Oct 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: wapsiii | last post by:
I have a form in which users must enter date and time. The users are spread out over several timezones and I'd like to load the form with the date/time of the current user. How do I get the...
9
by: ShaneFowlkes | last post by:
Hey guys... I have a form that asks for several dates. I tried using asp calendar controls to set values of the date textboxes which were readonly. I found this annoying since each time I...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
1
by: whitesmith | last post by:
I've read the FAQ about means of implementing a delay, but nothing seems to work for me. My HTML page looks like this: <html> <head> .... usual html stuff and then: <script...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
4
by: wolverine | last post by:
Hi, I want to get gmt in the format "MM/DD/YY HR:MIN:SEC". I have written the following code. Could any one of you suggest a better way ? var localTime = new Date(); var utc =...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.