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
396
votes
16 answers

How to add number of days to today's date?

I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery.
Linda725
  • 3,997
  • 3
  • 16
  • 5
394
votes
31 answers

jQuery UI DatePicker to show month year only

I am using jQuery date picker to display the calendar all over my app. I want to know if I can use it to display the month and year (May 2010) and not the calendar?
Aanu
  • 4,221
  • 4
  • 18
  • 15
393
votes
37 answers

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an HH-MM-SS string using JavaScript?
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
391
votes
48 answers

Calculate age given the birth date in the format YYYYMMDD

How can I calculate an age in years, given a birth date of format YYYYMMDD? Is it possible using the Date() function? I am looking for a better solution than the one I am using now: var dob = '19800810'; var year = Number(dob.substr(0, 4)); var…
Francisc
  • 77,430
  • 63
  • 180
  • 276
391
votes
13 answers

Select DataFrame rows between two dates

I am creating a DataFrame from a csv as follows: stock = pd.read_csv('data_in/' + filename + '.csv', skipinitialspace=True) The DataFrame has a date column. Is there a way to create a new DataFrame (or just overwrite the existing one) which only…
darkpool
  • 13,822
  • 16
  • 54
  • 89
389
votes
13 answers

Java Date vs Calendar

Could someone please advise the current "best practice" around Date and Calendar types. When writing new code, is it best to always favour Calendar over Date, or are there circumstances where Date is the more appropriate datatype?
Marty Pitt
  • 28,822
  • 36
  • 122
  • 195
385
votes
12 answers

Java 8: Difference between two LocalDateTime in multiple units

I am trying to calculate the difference between two LocalDateTime. The output needs to be of the format y years m months d days h hours m minutes s seconds. Here is what I have written: import java.time.Duration; import java.time.Instant; import…
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
384
votes
18 answers

How to convert timestamps to dates in Bash?

I need a shell command or script that converts a Unix timestamp to a date. The input can come either from the first parameter or from stdin, allowing for the following usage patterns: ts2date 1267619929 and echo 1267619929 | ts2date Both commands…
chiborg
  • 26,978
  • 14
  • 97
  • 115
383
votes
23 answers

How to convert date to timestamp in PHP?

How do I get timestamp from e.g. 22-09-2008?
Wizard4U
  • 3,997
  • 4
  • 19
  • 14
382
votes
20 answers

How to get year/month/day from a date object?

alert(dateObj) gives Wed Dec 30 2009 00:00:00 GMT+0800 How to get date in format 2009/12/30?
user198729
  • 61,774
  • 108
  • 250
  • 348
380
votes
18 answers

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s',…
Tom
  • 30,090
  • 27
  • 90
  • 124
376
votes
26 answers

How to format date and time in Android?

How to format correctly according to the device configuration date and time when having a year, month, day, hour and minute?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
376
votes
16 answers

Get integer value of the current year in Java

I need to determine the current year in Java as an integer. I could just use java.util.Date(), but it is deprecated.
karlgrz
  • 14,485
  • 12
  • 47
  • 58
371
votes
17 answers

Format date as dd/MM/yyyy using pipes

I'm using the date pipe to format my date, but I just can't get the exact format I want without a workaround. Am I understanding pipes wrongly or is just not possible? //our root app component import {Component} from 'angular2/core' @Component({ …
Jp_
  • 5,973
  • 4
  • 25
  • 36
366
votes
30 answers

How do I add 1 day to an NSDate?

Basically, as the title says. I'm wondering how I could add 1 day to an NSDate. So if it were: 21st February 2011 It would become: 22nd February 2011 Or if it were: 31st December 2011 It would become: 1st January 2012.
Andrew
  • 15,935
  • 28
  • 121
  • 203