Questions tagged [date]

A date is a reference to a particular day represented within a calendar system, and consists of year, month and day.

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

67828 questions
7152
votes
10 answers

Why is subtracting these two times (in 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
  • 177,284
  • 143
  • 381
  • 649
2671
votes
58 answers

How to format a JavaScript date?

In JavaScript, how can I format a date object to print as 10-Aug-2010?
leora
  • 163,579
  • 332
  • 834
  • 1,328
2570
votes
56 answers

How do I get the current date in JavaScript?

How do I get the current date in JavaScript?
Suresh
  • 33,939
  • 15
  • 55
  • 62
2238
votes
40 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
  • 33,445
  • 21
  • 43
  • 41
1920
votes
44 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?
eddiegroves
  • 30,153
  • 14
  • 44
  • 45
1706
votes
50 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
  • 66,082
  • 20
  • 111
  • 144
1438
votes
36 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,006
  • 5
  • 39
  • 49
1328
votes
50 answers

Add days to JavaScript Date

How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?
Ashesh
  • 13,349
  • 3
  • 16
  • 8
1324
votes
30 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
  • 25,570
  • 20
  • 66
  • 94
1219
votes
14 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
  • 17,761
  • 11
  • 33
  • 42
1215
votes
16 answers

Calculate difference between two dates (number of days)?

I see that this question has been answered for Java, JavaScript, and PHP, but not C#. So, how might one calculate the number of days between two dates in C#?
leora
  • 163,579
  • 332
  • 834
  • 1,328
1207
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
  • 17,035
  • 16
  • 45
  • 83
1174
votes
41 answers

How to get current time and date in Android

How can I get the current time and date in an Android app?
M7M
  • 11,791
  • 3
  • 13
  • 4
1164
votes
9 answers

Get the current year in JavaScript

How do I get the current year in JavaScript?
Satch3000
  • 40,202
  • 83
  • 203
  • 337
1021
votes
29 answers

How do I use PHP to get the current year?

I want to put a copyright notice in the footer of a web site, but I think it's incredibly tacky for the year to be outdated. How would I make the year update automatically with PHP 4 or PHP 5?
JD Graffam
  • 10,315
  • 2
  • 16
  • 6
1
2 3
99 100