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
393
votes
13 answers

Keep only date part when using pandas.to_datetime

I use pandas.to_datetime to parse the dates in my data. Pandas by default represents the dates with datetime64[ns] even though the dates are all daily only. I wonder whether there is an elegant/clever way to convert the dates to datetime.date or…
user1642513
391
votes
13 answers

Extracting just Month and Year separately from Pandas Datetime column

I have a Dataframe, df, with the following column: df['ArrivalDate'] = ... 936 2012-12-31 938 2012-12-29 965 2012-12-31 966 2012-12-31 967 2012-12-31 968 2012-12-31 969 2012-12-31 970 2012-12-29 971 2012-12-31 972 2012-12-29 973 …
monkeybiz7
  • 4,898
  • 5
  • 21
  • 35
385
votes
12 answers

Java 8: Difference between two LocalDateTime in multiple units

I am trying to calculate the difference between two LocalDateTime. The output needs to be of the format y years m months d days h hours m minutes s seconds. Here is what I have written: import java.time.Duration; import java.time.Instant; import…
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
383
votes
16 answers

How to get the current date or/and time in seconds

How do I get the current date or/and time in seconds using Javascript?
Hailwood
  • 89,623
  • 107
  • 270
  • 423
380
votes
18 answers

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s',…
Tom
  • 30,090
  • 27
  • 90
  • 124
377
votes
11 answers

Converting datetime.date to UTC timestamp in Python

I am dealing with dates in Python and I need to convert them to UTC timestamps to be used inside Javascript. The following code does not work: >>> d = datetime.date(2011,01,01) >>>…
user2665694
376
votes
16 answers

Get integer value of the current year in Java

I need to determine the current year in Java as an integer. I could just use java.util.Date(), but it is deprecated.
karlgrz
  • 14,485
  • 12
  • 47
  • 58
366
votes
10 answers

How to get the current date and time

How do I get the current date and time in Java? I am looking for something that is equivalent to DateTime.Now from C#.
mrblah
  • 99,669
  • 140
  • 310
  • 420
364
votes
17 answers

Get month name from number

How can I get the month name from the month number? For instance, if I have 3, I want to return march date.tm_month() How to get the string march?
Rajeev
  • 44,985
  • 76
  • 186
  • 285
362
votes
13 answers

Converting string to Date and DateTime

If I have a PHP string in the format of mm-dd-YYYY (for example, 10-16-2003), how do I properly convert that to a Date and then a DateTime in the format of YYYY-mm-dd? The only reason I ask for both Date and DateTime is because I need one in one…
Chris Pinski
  • 4,493
  • 3
  • 22
  • 16
358
votes
12 answers

Add default value of datetime field in SQL Server to a timestamp

I've got a table that collects forms submitted from our website, but for some reason, when they created the table, they didn't put a timestamp in the table. I want it to enter the exact date and time that the record was entered. I know it's in there…
stephmoreland
  • 4,053
  • 3
  • 21
  • 22
353
votes
8 answers

How do I compare two DateTime objects in PHP 5.2.8?

Having a look on the PHP documentation, the following two methods of the DateTime object would both seem to solve my problem: DateTime::diff : Get the difference and use that to determine which is more ancient. DateTime::getTimestamp : Get the UNIX…
RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
352
votes
15 answers

Format a datetime into a string with milliseconds

How can I format a datetime object as a string with milliseconds?
Jurudocs
  • 8,595
  • 19
  • 64
  • 88
352
votes
7 answers

UnsupportedTemporalTypeException when formatting Instant to String

I'm trying to format an Instant to a String using the new Java 8 Date and Time API and the following pattern: Instant instant = ...; String out = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(instant); Using the code above I get an…
Dag
  • 10,079
  • 8
  • 51
  • 74
352
votes
12 answers

Django auto_now and auto_now_add

For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) When updating a row I get: [Sun Nov 15 02:18:12 2009] [error]…
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213