Questions tagged [datetime]

A DateTime object in many programming languages describes a date and a time of day. It can express either an instant in time or a position on a calendar, depending on the context in which it is used and the specific implementation. This tag can be used for all date and time related issues.

A DateTime object in many programming languages describes a date and a time of day. It can express either an instant in time or a position on a calendar, depending on the context in which it is used and the specific implementation.

  • In , os.date and os.time are provided as part of lua's standard library for working with date and time.

  • In the data types TIMESTAMP [WITHOUT TIME ZONE] and TIMESTAMP WITH TIME ZONE are collectively referred to as timestamps. (And the data types DATE, TIME, and TIMESTAMP are collectively referred to as datetime types.)

  • In , datetime is a type that represents a date and time of day. It carries no time zone context, so it is a position on a calendar, not a moment in time.

  • In , DATETIME values represent a date and time of day. They carry no time zone context, so they are positions on a calendar, not a moment in time. TIMESTAMP values represent a moment in time, and are based on UNIX time. When MySQL stores TIMESTAMPs, it converts them from the current connection's time zone setting to UTC. When displaying them it converts them back.

  • In , DateTime is a structure that is typically expressed as a date and time of day. It represents either an instant in time, or a position on a calendar. The precise meaning is dependent on the value of its Kind property.

  • In , Instant is a class that represents an instant in time. Before Java 8 was a popular library, DateTime is a class which represents an instant in time, with reference to a particular time zone.

  • In , datetime is an object which represents a date and time of day. The precise meaning is dependent on the value of its tzinfo property. It is also the name of the module that provides date, time, datetime, and related objects.

  • In the DateTime class is a representation of a instant in time, with reference to a particular time zone.

  • In , the time and date manipulation library datetime-fortran can be used.

  • In , a Date instance represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC. That is, they are UNIX time values in milliseconds.

  • In , the classes "POSIXlt" and "POSIXct" represent calendar dates and times.Subtraction of two date-time objects is equivalent to using difftime. Class "POSIXct" represents the (signed) number of seconds since the beginning of 1970 (in the UTC time zone) as a numeric vector. Class "POSIXlt" is a named list of vectors representing sec, min, hour et al

  • In , Microsoft Excel for Windows uses the 1900 date system, by default. Which means the first date is January 1, 1900. a Date and Time function can be used to manipulate the year/date and time/hour/minutes values. The date/time in Excel is stored as a number. Where the decimal part range from 0.0 to 0.99988426 represent 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.), and the integer part range from 0 to 9999 represent days. But Excel's date representation is slightly off in the first two months of calendar year 1900.


Helpful articles

70365 questions
524
votes
39 answers

Convert UTC date time to local date time

From the server I get a datetime variable in this format: 6/29/2011 4:52:48 PM and it is in UTC time. I want to convert it to the current user’s browser time zone using JavaScript. How this can be done using JavaScript or jQuery?
Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
517
votes
11 answers

What is the standard way to add N seconds to datetime.time in Python?

Given a datetime.time value in Python, is there a standard way to add an integer number of seconds to it, so that 11:34:59 + 3 = 11:35:02, for example? These obvious ideas don't work: >>> datetime.time(11, 34, 59) + 3 TypeError: unsupported operand…
Paul Stephenson
  • 67,682
  • 9
  • 49
  • 51
514
votes
17 answers

How to convert java.util.Date to java.sql.Date?

I am trying to use a java.util.Date as input and then creating a query with it - so I need a java.sql.Date. I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the…
David Ackerman
  • 12,649
  • 6
  • 24
  • 19
508
votes
7 answers

How to compare two dates?

How would I compare two dates to see which is later, using Python? For example, I want to check if the current date is past the last date in this list I am creating, of holiday dates, so that it will send an email automatically, telling the admin to…
Steven Matthews
  • 9,705
  • 45
  • 126
  • 232
494
votes
16 answers

Is DateTime.Now the best way to measure a function's performance?

I need to find a bottleneck and need to accurately as possible measure time. Is the following code snippet the best way to measure the performance? DateTime startTime = DateTime.Now; // Some execution process DateTime endTime =…
David Basarab
  • 72,212
  • 42
  • 129
  • 156
491
votes
8 answers

How do I query for all dates greater than a certain date in SQL Server?

I'm trying: SELECT * FROM dbo.March2010 A WHERE A.Date >= 2010-04-01; A.Date looks like: 2010-03-04 00:00:00.000 However, this is not working. Can anyone provide a reference for why?
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
483
votes
33 answers

How do you display JavaScript datetime in 12 hour AM/PM format?

How do you display a JavaScript datetime object in the 12 hour format (AM/PM)?
bbrame
  • 18,031
  • 10
  • 35
  • 52
482
votes
19 answers

How do I get a value of datetime.today() in Python that is "timezone aware"?

I am trying to subtract one date value from the value of datetime.datetime.today() to calculate how long ago something was. But it complains: TypeError: can't subtract offset-naive and offset-aware datetimes The return value from…
mindthief
  • 12,755
  • 14
  • 57
  • 61
477
votes
18 answers

Convert from MySQL datetime to another format with PHP

I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
Tim Boland
  • 10,127
  • 8
  • 27
  • 25
474
votes
12 answers

Can't subtract offset-naive and offset-aware datetimes

I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it's age. The problem I'm having is that both datetime.datetime.now() and datetime.datetime.utcnow()…
Ian
  • 24,116
  • 22
  • 58
  • 96
474
votes
15 answers

Convert datetime object to a String of date only in Python

I see a lot on converting a date string to an datetime object in Python, but I want to go the other way. I've got datetime.datetime(2012, 2, 23, 0, 0) and I would like to convert it to string like '2/23/2012'.
wilbev
  • 5,391
  • 7
  • 28
  • 30
473
votes
13 answers

How can I convert a datetime object to milliseconds since epoch (unix time) in Python?

I have a Python datetime object that I want to convert to unix time, or seconds/milliseconds since the 1970 epoch. How do I do this?
SuperString
  • 21,593
  • 37
  • 91
  • 122
472
votes
11 answers

How can I parse/format dates with LocalDateTime? (Java 8)

Java 8 added a new java.time API for working with dates and times (JSR 310). I have date and time as string (e.g., "2014-04-08 12:30"). How can I obtain a LocalDateTime instance from the given string? After I finished working with the LocalDateTime…
micha
  • 47,774
  • 16
  • 73
  • 80
471
votes
16 answers

How do I get the last day of a month?

How can I find the last day of the month in C#? For example, if I have the date 03/08/1980, how do I get the last day of month 8 (in this case 31)?
Gold
  • 60,526
  • 100
  • 215
  • 315
466
votes
7 answers

Convert Pandas Column to DateTime

I have one field in a pandas DataFrame that was imported as string format. It should be a datetime variable. How do I convert it to a datetime column, and then filter based on date? Example: raw_data = pd.DataFrame({'Mycol':…
Chris
  • 12,900
  • 12
  • 43
  • 65