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
1033
votes
26 answers

How do you set a default value for a MySQL Datetime column?

How do you set a default value for a MySQL Datetime column? In SQL Server it's getdate(). What is the equivalant for MySQL? I'm using MySQL 5.x if that is a factor.
Brian Boatright
  • 36,294
  • 34
  • 81
  • 102
1012
votes
19 answers

Given a DateTime object, how do I get an ISO 8601 date in string format?

Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ
Iain
  • 12,269
  • 6
  • 24
  • 13
993
votes
10 answers

How do I convert a datetime to date?

How do I convert a datetime.datetime object (e.g., the return value of datetime.datetime.now()) to a datetime.date object in Python?
niklasfi
  • 15,245
  • 7
  • 40
  • 54
969
votes
23 answers

How can I convert a Unix timestamp to DateTime and vice versa?

There is this example code, but then it starts talking about millisecond / nanosecond problems. The same question is on MSDN, Seconds since the Unix epoch in C#. This is what I've got so far: public Double CreatedEpoch { get { DateTime epoch…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
968
votes
10 answers

Is there a list of Pytz Timezones?

I would like to know what are all the possible values for the timezone argument in the Python library pytz. How to do it?
ipegasus
  • 14,796
  • 9
  • 52
  • 76
955
votes
14 answers

Convert date to datetime in Python

Is there a built-in method for converting a date to a datetime in Python, for example getting the datetime for the midnight of the given date? The opposite conversion is easy: datetime has a .date() method. Do I really have to manually call…
EMP
  • 59,148
  • 53
  • 164
  • 220
908
votes
12 answers

Getting today's date in YYYY-MM-DD in Python?

Is there a nicer way than the following to return today's date in the YYYY-MM-DD format? str(datetime.datetime.today()).split()[0]
Pyderman
  • 14,809
  • 13
  • 61
  • 106
905
votes
29 answers

How do I parse an ISO 8601-formatted date?

I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type. I have found strptime in the Python standard library, but it is not very convenient. What is the best way to do this?
Alexander Artemenko
  • 21,378
  • 8
  • 39
  • 36
890
votes
31 answers

How do I get the day of week given a date?

I want to find out the following: given a date (datetime object), what is the corresponding day of the week? For instance, Sunday is the first day, Monday: second day.. and so on And then if the input is something like today's date. Example >>>…
frazman
  • 32,081
  • 75
  • 184
  • 269
880
votes
17 answers

DateTime2 vs DateTime in SQL Server

Which one: datetime datetime2 is the recommended way to store date and time in SQL Server 2008+? I'm aware of differences in precision (and storage space probably), but ignoring those for now, is there a best practice document on when to use…
Mikeon
  • 10,499
  • 6
  • 27
  • 31
866
votes
7 answers

Get current time in seconds since the Epoch on Linux, Bash

I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds. date doesn't seem to offer that option. Is there an easy way?
n-alexander
  • 14,663
  • 12
  • 42
  • 43
831
votes
28 answers

How to get the current date/time in Java

What's the best way to get the current date/time in Java?
user496949
  • 83,087
  • 147
  • 309
  • 426
818
votes
34 answers

How to calculate the difference between two dates using PHP?

I have two dates of the form: Start Date: 2007-03-24 End Date: 2009-06-26 Now I need to find the difference between these two in the following form: 2 years, 3 months and 2 days How can I do this in PHP?
gnanesh
812
votes
25 answers

How to print a date in a regular format?

This is my code: import datetime today = datetime.date.today() print(today) This prints: 2008-11-22 which is exactly what I want. But, I have a list I'm appending this to and then suddenly everything goes "wonky". Here is the code: import…
NomadAlien
  • 9,090
  • 6
  • 25
  • 22
787
votes
18 answers

MySQL Query GROUP BY day / month / year

Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE record_date.YEAR = 2009 GROUP BY…
Fernando Barrocal
  • 12,584
  • 9
  • 44
  • 51