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
786
votes
35 answers

Finding the number of days between two dates

How to find number of days between two dates using PHP?
PHP Ferrari
  • 15,754
  • 27
  • 83
  • 149
781
votes
18 answers

C# DateTime to "YYYYMMDDHHMMSS" format

I want to convert a C# DateTime to "YYYYMMDDHHMMSS" format. But I don't find a built in method to get this format? Any comments?
SARAVAN
  • 14,571
  • 16
  • 49
  • 70
773
votes
16 answers

How do I get the current time in milliseconds in Python?

How do I get the current time in milliseconds in Python?
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
767
votes
17 answers

Converting a String to DateTime

How do you convert a string such as 2009-05-08 14:40:52,531 into a DateTime?
dban
751
votes
16 answers

How to calculate number of days between two given dates

If I have two dates (ex. '8/18/2008' and '9/26/2008'), what is the best way to get the number of days between these two dates?
Ray
  • 187,153
  • 97
  • 222
  • 204
706
votes
20 answers

How do I convert seconds to hours, minutes and seconds?

I have a function that returns information in seconds, but I need to store that information in hours:minutes:seconds. Is there an easy way to convert the seconds to this format in Python?
Specto
  • 8,271
  • 5
  • 23
  • 20
696
votes
8 answers

How to clone a Date object?

Assigning a Date variable to another one will copy the reference to the same instance. This means that changing one will change the other. How can I actually clone or copy a Date instance?
634
votes
15 answers

ISO time (ISO 8601) in Python

I have a file. In Python, I would like to take its creation time, and convert it to an ISO time (ISO 8601) string while preserving the fact that it was created in the Eastern Time Zone (ET). How do I take the file's ctime and convert it to an ISO…
Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
630
votes
18 answers

Adding days to a date in Python

I have a date "10/10/11(m-d-y)" and I want to add 5 days to it using a Python script. Please consider a general solution that works on the month ends also. I am using following code: import re from datetime import datetime StartDate =…
MuraliKrishna
  • 6,577
  • 3
  • 18
  • 11
628
votes
30 answers

How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date. See @npocmaka's…
Rory
  • 40,559
  • 52
  • 175
  • 261
611
votes
9 answers

Converting between java.time.LocalDateTime and java.util.Date

Java 8 has a completely new API for date and time. One of the most useful classes in this API is LocalDateTime, for holding a timezone-independent date-with-time value. There are probably millions of lines of code using the legacy class…
Knut Arne Vedaa
  • 15,372
  • 11
  • 48
  • 59
602
votes
43 answers

How to remove time portion of date in C# in DateTime object only?

I need to remove time portion of date time or probably have the date in following format in object form not in the form of string. 06/26/2009 00:00:00:000 I can not use any string conversion methods as I need the date in object form. I tried first…
im useless
  • 7,151
  • 7
  • 35
  • 49
601
votes
14 answers

Convert java.util.Date to java.time.LocalDate

What is the best way to convert a java.util.Date object to the new JDK 8/JSR-310 java.time.LocalDate? Date input = new Date(); LocalDate date = ???
JodaStephen
  • 60,927
  • 15
  • 95
  • 117
596
votes
11 answers

How do I translate an ISO 8601 datetime string into a Python datetime object?

I'm getting a datetime string in a format like "2009-05-28T16:15:00" (this is ISO 8601, I believe). One hackish option seems to be to parse the string using time.strptime and passing the first six elements of the tuple into the datetime constructor,…
Andrey Fedorov
  • 9,148
  • 20
  • 67
  • 99
595
votes
23 answers

Best approach to remove time part of datetime in SQL Server

Which method provides the best performance when removing the time portion from a datetime field in SQL Server? a) select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) or b) select cast(convert(char(11), getdate(), 113) as datetime) The second method…
Stephen Perelson
  • 6,613
  • 3
  • 21
  • 15