Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string.
If you want it similar to Unix timestamp you probably want it in seconds : Math.round(new Date().getTime() / 1000)
radius
2010-06-30 14:39:10
I like `+new Date()`, more badass, or even if it's just to confuse the JS newbies. (coherces Date object into Number)
Infinity
2010-07-23 19:16:36
Should it be in UTC? If so how is it converted?
Adam
2010-08-09 19:30:00
+2
A:
I don't have enough points to add a comment to daveb's accepted answer but I think it's worth saying, so I hope you don't mind me putting it here.
One benefit of his way is that the same syntax can be found in other languages. For instance, the following code will give you the exact same timestamp in Java or Scala:
(new java.util.Date()).getTime();
pr1001
2009-07-11 01:24:52
+1
A:
time = Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
Kiragaz
2009-11-11 11:38:57
A:
Is there a solution to disable caching when making the POST/GET
Yes, use jQuery and have a look at the Ajax tutorials.
Jason
2010-01-31 23:02:27
Does IE cache POST requests? I considered going that route but heard that POST actually generates two requests.
Drew
2010-06-01 18:09:08
A:
var d=new Date();
var timestamp = new Array(2);
timestamp[1] = d.getDate();
timestamp[2] = d.getMonth();
document.write(timestamp[1]);
switch (timestamp[2])
{
case 0: document.write("Jan");
break;
case 1: document.write("Feb");
break;
case 2: document.write("Mar");
break;
case 3: document.write("Apr");
break;
case 4: document.write("May");
break;
case 5: document.write("June");
break;
case 6: document.write("July");
break;
case 7: document.write("Aug");
break;
case 8: document.write("Sept");
break;
case 9: document.write("Oct");
break;
case 10: document.write("Nov");
break;
case 11: document.write("Dec");
break;
}
Douglas Gross
2010-02-25 02:31:00