Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [date]

A date is a reference to a particular day represented within a calendar system, and consists of year, month and day. Use for questions about creating, manipulating and storing date information. Use with any relevant language tags.

7570 votes
11 answers
806k views

Why is subtracting these two epoch-milli Times (in year 1927) giving a strange result?

If I run the following program, which parses two date strings referencing times 1 second apart and compares them: public static void main(String[] args) throws ParseException { SimpleDateFormat sf ...
Freewind's user avatar
  • 197k
3531 votes
71 answers
6.8m views

How do I format a date in JavaScript?

How do I format a Javascript Date object as a string? (Preferably in the format: 10-Aug-2010)
leora's user avatar
  • 194k
3017 votes
63 answers
4.3m views

How do I get the current date in JavaScript?

How do I get the current date in JavaScript?
Suresh's user avatar
  • 39.2k
2802 votes
48 answers
3.4m views

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.
Alex's user avatar
  • 40k
2188 votes
47 answers
3.8m views

How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00:00:00.000 How can I get that?
Eddie Groves's user avatar
  • 34.5k
2156 votes
56 answers
1.6m views

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 Date' console.log(...
orip's user avatar
  • 74.9k
1759 votes
55 answers
2.3m views

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()?
Ashesh's user avatar
  • 17.7k
1668 votes
35 answers
2.6m views

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.
roflwaffle's user avatar
  • 30.4k
1609 votes
13 answers
1.3m views

Get the current year in JavaScript

How do I get the current year in JavaScript?
Satch3000's user avatar
  • 48.8k
1547 votes
18 answers
2.1m views

YYYY-MM-DD format date in shell script

I tried using $(date) in my bash shell script, however, I want the date in YYYY-MM-DD format. How do I get this?
Kapsh's user avatar
  • 21.6k
1512 votes
40 answers
1.6m views

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:39") Xmas95 = new ...
1475 votes
17 answers
1.7m views

How to calculate difference between two dates (number of days)?

How can one calculate the number of days between two dates in C#?
leora's user avatar
  • 194k
1300 votes
44 answers
1.8m views

How to get current time and date in Android

How can I get the current time and date in an Android app?
M7M's user avatar
  • 13.1k
1289 votes
29 answers
1.4m views

Sort ArrayList of custom Objects by property

I read about sorting ArrayLists using a Comparator but in all of the examples people used compareTo which according to some research is a method for Strings. I wanted to sort an ArrayList of custom ...
Samuel's user avatar
  • 18.5k
1206 votes
56 answers
3.0m views

Format JavaScript date as yyyy-mm-dd

I have a date with the format Sun May 11,2014. How can I convert it to 2014-05-11 using JavaScript? function taskDate(dateMilli) { var d = (new Date(dateMilli) + '').split(' '); d[2] = ...
user3625547's user avatar
  • 12.1k

15 30 50 per page
1
2 3 4 5
5133