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
22
votes
2 answers

Why converting new.Date() .toISOString() changes the time?

I'm inserting a date in a database in two different format. this is inserting as Datetime var mydate; mydate = new Date(); document.getElementById('clockinhour').value = mydate.toISOString().slice(0, 19).replace('T', ' '); Output…
Sebastian Farham
  • 815
  • 2
  • 13
  • 27
22
votes
7 answers

Regarding JavaScript new Date() and Date.parse()

var exampleDate='23-12-2010 23:12:00'; I want to convert above string into a date and have tried a couple things: var date = new Date(exampleDate); //returns invalid Date var date1 = Date.parse(exampleDate); //returns NAN This code is running…
Chitresh
  • 3,022
  • 12
  • 35
  • 40
22
votes
2 answers

DateFormatter doesn't return date for "HH:mm:ss"

Here is the code excerpt: func mapping(map: Map) { time <- (map["time"], TransformOf(fromJSON: { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "HH:mm:ss" //dateFormatter.timeZone =…
muvaf
  • 323
  • 4
  • 9
22
votes
4 answers

Convert text date/time to a real date time in excel

My data is extracted from an application and it has a text that looks like a date/time in excel. How do I actually convert "3/24/2016 11:22:07 PM" (in text) to a real date/time conversion? I've tried formatting the cells but it doesn't work.
user3085606
  • 253
  • 1
  • 2
  • 7
22
votes
9 answers

Month Array in JavaScript Not Pretty

How can i make it nicer? var month = new Array(); month['01']='Jan'; month['02']='Feb'; month['03']='Mar'; etc. Itd be nice to do it like: var months = new Array(['01','Jan'],['02','Feb'],['03','Mar']); For example. anyway like that to simplify…
Oscar Godson
  • 31,662
  • 41
  • 121
  • 201
22
votes
1 answer

Java 8 Date API vs Calendar / Date / DateFormat

There is this new-n-cool Date API in Java 8, the java.time package. I understand that it is better designed, less ambiguous and more thread-safe than the old classes. Still, I am not sure how to go about using it: Should I use it exclusively…
Fritz Duchardt
  • 11,026
  • 4
  • 41
  • 60
22
votes
2 answers

Convert quarter/year format to a date

I created a function that coerce a vector of quarters-years format to a vector of dates. .quarter_to_date(c("Q1/13","Q2/14")) [1] "2013-03-01" "2014-06-01" This the code of my function. .quarter_to_date <- function(x){ ll <-…
agstudy
  • 119,832
  • 17
  • 199
  • 261
22
votes
5 answers

How to add one day to a time obtained from time()

I have a time represented as the number of seconds elapsed since midnight, January 1, 1970, UTC (the results of an earlier call to time()). How do I add one day to this time? Adding 24 * 60 * 60 works in most cases, but fails if the daylight saving…
Andrew Stein
  • 12,880
  • 5
  • 35
  • 43
22
votes
3 answers

is there any workaround for broken v8 date parser?

V8 Date parser is broken: > new Date('asd qw 101') Sat Jan 01 101 00:00:00 GMT+0100 (CET) I can use fragile regular expression like this: \d{1,2} (jan|feb|mar|may|jun|jul|aug|sep|oct|nov|dec) \d{1,4} but it is too fragile. I cannot rely on new…
Vladimir Starkov
  • 19,264
  • 8
  • 60
  • 114
22
votes
10 answers

Get month in mm format in javascript

How do I retrieve the month from the current date in mm format? (i.e. "05") This is my current code: var currentDate = new Date(); var currentMonth = currentDate.getMonth() + 1;
Michael Kniskern
  • 24,792
  • 68
  • 164
  • 231
22
votes
8 answers

How to calculate Number of 'Working days' between two dates in Javascript using moment.js?

How to calculate the number of working days between two dates in JavaScript using moment.js. I have a working formula that calculate these days, but the formula does not satisfies all conditions: here is my code: var start=…
Ali Shaan
  • 345
  • 1
  • 2
  • 10
22
votes
8 answers

Remove time from GMT time format

I am getting a date that comes in GMT format, Fri, 18 Oct 2013 11:38:23 GMT. The problem is that the time is messing up the timeline that I am using. How can I strip out everything except for the actual date?
Grady D
  • 1,889
  • 6
  • 30
  • 61
22
votes
2 answers

How to parse a date string in PHP?

With a date string of Apr 30, 2010, how can I parse the string into 2010-04-30 using PHP?
user295515
  • 877
  • 3
  • 8
  • 12
22
votes
6 answers

Detect with javascript if user's machine is using 12 hour clock (am/pm) or 24 clock (military time)

Is it possible to detect if user's machine is using 12 hour clock (am/pm) or 24 hour clock (military time)? One way would be to check users locales, but then it is just massive list of locale comparison and someone from U.S who wants 12 hour clock…
Badr Hari
  • 8,114
  • 18
  • 67
  • 100
22
votes
4 answers

Swift iOS doesRelativeDateFormatting have different values besides "Today" and "Yesterday"?

I have a number of dates that I am trying to represent using a relative date such as "Today, Yesterday, 1 week ago, 1 month ago" etc... This is the Swift code I am using: let dateFormatter = NSDateFormatter() dateFormatter.dateStyle =…
Justin W.
  • 221
  • 1
  • 2
  • 3
1 2 3
99
100