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
23
votes
7 answers

how to get date for holidays using php

For example the: 3rd Monday of January for Martin Luther King Day 3rd Monday of February for Presidents' Day (Washington's Birthday) Last Sunday of March for Easter Last Monday of May for Memorial Day I am trying to get these dates, so that…
telexper
  • 2,381
  • 8
  • 37
  • 66
23
votes
8 answers

What is a good, simple way to compute ISO 8601 week number?

Suppose I have a date, i.e. year, month and day, as integers. What's a good (correct), concise and fairly readable algorithm for computing the ISO 8601 week number of the week the given date falls into? I have come across some truly horrendous code…
user9511
  • 231
  • 1
  • 2
  • 3
23
votes
2 answers

Does UTC date string require the format specifier "Z" even if that string includes time offset?

For instance, const d = new Date("2012-08-20T15:00:00-07:00"); d here is a UTC time with time offset = 07:00. Does it still require Z like this 2012-08-20T15:00:00-07:00Z? Is this correct? If I take this string with Z and parse it using…
Cute_Ninja
  • 4,742
  • 4
  • 39
  • 63
23
votes
3 answers

Convert DateInterval object to seconds in php

$datetime1 = date_create('2009-10-11'); $datetime2 = date_create('2009-10-13'); $interval = date_diff($datetime1, $datetime2); How do i convert the above $interval to seconds in php
sanchitkhanna26
  • 2,143
  • 8
  • 28
  • 42
23
votes
3 answers

mysql date comparison with date_format

I googled and tried several ways to compare date but unfortunately didn't get the result as expected. I have current state of records like following: mysql> select date_format(date(starttime),'%d-%m-%Y') from data; …
Doni Andri Cahyono
  • 793
  • 5
  • 16
  • 28
23
votes
5 answers

Change day of the month in a Date to first day (01)

I want to set the day of month in a Date to start date of current month (01). Now I use the following: currentDate <- Sys.Date() #for getting current system date eg:2012-11-06 formatDate <- format(currentDate, "%Y-%m") #it return 2012-11 startDate…
Nandu
  • 3,076
  • 8
  • 34
  • 51
23
votes
8 answers

How to derive current date and time and append at the end of each line that contains 'Hello'

I have the following file party.txt that contains something like the following: Hello Jacky Hello Peter Bye Johnson Hello Willy Bye Johnny Hello Mary Hello Wendy I used the grep hello to capture the contents, but when I use the print date…
Jack
  • 1,603
  • 5
  • 25
  • 36
23
votes
4 answers

Previous weekday in Python

In Python, given a date, how do I find the preceding weekday? (Weekdays are Mon to Fri. I don't care about holidays)
Lobert
  • 467
  • 1
  • 4
  • 10
23
votes
5 answers

Oracle: subtract millisecond from a datetime

I thought it was really simple but it isn't. SELECT TO_TIMESTAMP('10/08/2012','DD/MM/YYYY') - 1/(24*50*60*1000) data FROM dual; It simply doesn't work. Other details: SELECT TO_TIMESTAMP('10/08/2012','DD/MM/YYYY') - …
Revious
  • 7,816
  • 31
  • 98
  • 147
23
votes
3 answers

Why does Date exist in Ruby before it is required?

In Ruby, I'd expect that a class which has not been required would raise an "uninitialized constant" error. This is the case with CSV, for instance. However, Date behaves strangely: it is available, but apparently does not work, until it is…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
22
votes
8 answers

adding 30 minutes to date

So what I need to do is add 30 minutes to the following date("Ymdhis"); I tried this +strtotime("+30 minutes"); however it does not seem to like it. I wondering what the correct why to do this is.
RussellHarrower
  • 6,470
  • 21
  • 102
  • 204
22
votes
2 answers

cbind() is changing date formatting

I'm trying to create a subset of a data frame and when I do so, R switches the formatting of the date column. Any idea why or how to fix this? > head(spyPr2) Date Open High Low Close Volume Adj.Close 1 12/30/2011 126.02 126.33…
screechOwl
  • 27,310
  • 61
  • 158
  • 267
22
votes
6 answers

Create a regular sequence of date-times (POSIXct) using seq()

My goal is to create a vector of POSIXct time stamps given a start, an end and a delta (15min, 1hour, 1day). I hoped I could use seq for this, but I have a problem converting between the numeric and POSIXct representation: now <- Sys.time() now #…
Karsten W.
  • 17,826
  • 11
  • 69
  • 103
22
votes
3 answers

how to delete firstdigit 0 from date and month

Code: $today_mem = date("d.m"); echo $today_mem; // -> 15.02 I need to transform dates like 15.02 into 15.2, also need to transform for ex. 07.02 into 7.2 and so on every day. So the question is: how to delete firstdigit 0 from date and month. Any…
966p
  • 535
  • 2
  • 7
  • 17
22
votes
5 answers

Why does Javascript evaluate a 2-digit year of 00 as 1900 instead of 2000?

I have an old web app where Javascript is used to validate some dates. Users usually use 2-digit years and I recently discovered it was evaluating 00 as 1900 instead of 2000 if (new Date(tb[0].value) > new Date(tb[1].value)){ alert('Starting…
Rachel
  • 130,264
  • 66
  • 304
  • 490