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.

A date is an ambiguous interval in time, which usually refers to a day, month, and year in a particular calendar system.

A date by itself (such as Jan 1 2014) does not refer to a specific moment in time.

  • It does not have a time of day, so it refers to a whole calendar date.
  • It does not specify a time zone, so it could be interpreted differently by each viewer.

Related concepts such as "today", "yesterday", and "tomorrow", or any individual day of the week such as "Monday" or "Tuesday", also have the same qualities. They are loose terms that require a time zone in order to lock in to a specific range of time.

In some programming languages, such as , the Date type actually represents a date and time of day and is therefore misnamed.

The most recognized calendar is the Gregorian calendar, but there are other known calendars such as the Hebrew or the Hijri (Muslim) calendar. Since both start at a different date from the Gregorian calendar's date, the dates in these calendars are different. When one intends to implement an international application or website, the different calendars might be good to be taken into account.

See also: , , and

76185 questions
7506
votes
10 answers

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 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); …
Freewind
  • 193,756
  • 157
  • 432
  • 708
3434
votes
69 answers

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
  • 188,729
  • 360
  • 878
  • 1,366
2975
votes
61 answers

How do I get the current date in JavaScript?

How do I get the current date in JavaScript?
Suresh
  • 38,717
  • 16
  • 62
  • 66
2743
votes
48 answers

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
  • 39,265
  • 21
  • 45
  • 42
2157
votes
46 answers

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
  • 33,851
  • 14
  • 47
  • 48
2081
votes
54 answers

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(typeof d); // shows 'object' console.log(d instanceof…
orip
  • 73,323
  • 21
  • 116
  • 148
1691
votes
55 answers

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
  • 16,995
  • 3
  • 18
  • 8
1612
votes
34 answers

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
  • 29,590
  • 21
  • 71
  • 94
1539
votes
12 answers

Get the current year in JavaScript

How do I get the current year in JavaScript?
Satch3000
  • 47,356
  • 86
  • 216
  • 346
1501
votes
39 answers

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 Date("20 09 2006,12:52:39") I could not find…
Naga Kiran
  • 8,585
  • 5
  • 43
  • 53
1469
votes
18 answers

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
  • 20,751
  • 13
  • 36
  • 44
1439
votes
17 answers

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

How can one calculate the number of days between two dates in C#?
leora
  • 188,729
  • 360
  • 878
  • 1,366
1284
votes
43 answers

How to get current time and date in Android

How can I get the current time and date in an Android app?
M7M
  • 12,891
  • 3
  • 15
  • 4
1279
votes
29 answers

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 objects by one of their properties: a Date…
Samuel
  • 18,286
  • 18
  • 52
  • 88
1147
votes
8 answers

How to subtract a day from a date?

I have a Python datetime.datetime object. What is the best way to subtract one day?
defrex
  • 15,735
  • 7
  • 34
  • 45
1
2 3
99 100