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
8 answers

Incrementing a java.util.Date by one day

What is the correct way to increment a java.util.Date by one day. I'm thinking something like Calendar cal = Calendar.getInstance(); cal.setTime(toDate); cal.add(Calendar.DATE, 1); toDate = cal.getTime(); It doesn't…
Anthony
  • 1,685
  • 4
  • 22
  • 29
23
votes
9 answers

How to check if variable is Date or Time or DateTime in Ruby?

Any easy way to check if a variable / object is of Date / Time / DateTime type? Without naming all the types
Aurimas
  • 2,577
  • 5
  • 26
  • 37
23
votes
5 answers

How to convert decimal hour value to hh:mm:ss

How can I convert a decimal hour value like 1.6578 to hh:mm:ss in jquery or javascript? I only managed to do it to hh:mm using this code: var decimaltime= "1.6578"; var hrs = parseInt(Number(decimaltime)); var min =…
user5563910
23
votes
3 answers

What's the best way to convert a Date to a DateTime in the current timezone in Rails 4?

I'm using Rails 4.2. I have a Date that I'd like to convert to a DateTime. If I use the existing to_datetime method, it converts it in GMT. (I've looked at threads for about an hour now and couldn't find this exact problem so apologies in advance if…
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
23
votes
7 answers

What's the simplest way to decrement a date in Javascript by 1 day?

I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'. It always seems to take more code than necessary when I do this, so…
ChrisThomas123
  • 2,578
  • 4
  • 23
  • 20
23
votes
4 answers

How to find Previous Sunday in R

It seems the Internet has not answered this question for R yet: If I have a date. Say the 20th of march: as.Date("2015-03-20") how do I get, in R, the previous Sunday? i.e., in the above example, as.Date("2015-03-15").
patapouf_ai
  • 17,605
  • 13
  • 92
  • 132
23
votes
3 answers

check format of date with moment.js

I am taking input from calendar in my screen which is of this type DD-MMM-YYYY HH:mm a but user can provide date from keyboard. Now I have to check whether user has provided the date in correct format or not. I am heavily using moment.js in my…
rishi
  • 1,792
  • 5
  • 31
  • 63
23
votes
2 answers

Trunc date field in mysql like Oracle

I am to not able to use the 'trunc(in oracle)' function in 'mysql' database. I have a table called dlb_cc_purchase and date field called due_date in my 'mysql' database. The data displaying in the date field like 20-11-2014 00:00:00 (20-nov-2014).…
Prajith A S
  • 457
  • 3
  • 8
  • 23
23
votes
5 answers

Mayan calendar in Java

How can I use the Maya calendar in Java?
user304034
23
votes
3 answers

Pandas Merge on Name and Closest Date

I am trying to merge two dataframes on both name and the closest date (WRT the left hand dataframe). In my research I found one similar question here but it doesn't account for the name as well. From the above question it doesn't seem like there is…
sfortney
  • 2,075
  • 6
  • 23
  • 43
23
votes
2 answers

Javascript method to find number of milliseconds from 1970-01-01?

Say, I have a date var dt = new Date('2012-01-01'); Is there a method in Javascript to return number of milliseconds since 1970-01-01? For this particulat date it would return 1325376000000 For this purpose, there is a method "toUTC()" that runs…
Cute_Ninja
  • 4,742
  • 4
  • 39
  • 63
23
votes
4 answers

How to check if a certain date is passed

I have a string of the form "mm/yyyy" and I want to compare it against the date of the local system. I have thought of either using a conversion table between my month and the MONTH field in Calendar, something like: Calendar cal =…
user2891462
  • 3,033
  • 2
  • 32
  • 60
23
votes
7 answers

Highlight dates in specific range with jQuery's datepicker

I need to highlight the dates between a start date and an end date, which I should be able to specify. Can anyone help me?
user286928
23
votes
6 answers

How to convert hours and minutes to minutes with moment.js?

I need to convert hours and minutes in minutes values. With pure JavaScript Date object I do the following: var d = new Date(); var minutes = d.getHours() * 60 + d.getMinutes(); I've just switched to moment.js and looking for better solution likes…
Erik
  • 14,060
  • 49
  • 132
  • 218
23
votes
5 answers

What was the date 180 days ago?

How would I get the date 180 days ago using C#?
Jamie
  • 2,465
  • 10
  • 28
  • 31