日期與時間

日期解析、格式化與時間計算。

9 / 9 題 · 依票數排序

4.9k

How do I get a timestamp in JavaScript?

I want a single number that represents the current date and time, like a Unix timestamp .

2008javascriptdatetimetimestampdate-arithmetic·3 重點答案·4.7M 次瀏覽
3.6k

How do I format a date in JavaScript?

How do I format a Javascript Date object as a string? (Preferable format: 10-Aug-2010 )

2010javascriptdatedatetimedatetime-formatdate-formatting·3 重點答案·7.1M 次瀏覽
2.9k

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.

2009javascriptdatedatetimecompare·3 重點答案·3.6M 次瀏覽
2.2k

Detecting an "invalid date" Date instance in JavaScript

I'd like to tell the difference between valid and invalid date objects in JS, but couldn't figure out how: var d = new Date("foo"); console.log(d.toString()); // shows 'Invalid Da…

2009javascriptdate·3 重點答案·1.7M 次瀏覽
1.8k

How to add days to Date?

How to add days to current Date using JavaScript? Does JavaScript have a built in function like .NET's AddDay() ?

2009javascriptdate·3 重點答案·2.4M 次瀏覽
1.7k

Convert a Unix timestamp to time in JavaScript

I am storing time in a MySQL database as a Unix timestamp and that gets sent to some JavaScript code. How would I get just the time out of it? For example, in HH/MM/SS format.

2009javascriptdatetimetime-format·3 重點答案·2.7M 次瀏覽
1.5k

Where can I find documentation on formatting a date in JavaScript?

I noticed that JavaScript's new Date() function is very smart in accepting dates in several formats. Xmas95 = new Date("25 Dec, 1995 23:15:00") Xmas95 = new Date("2009 06 12,12:52…

2009javascriptdatedatetime-formatjava-dateformattime-format·3 重點答案·1.6M 次瀏覽