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
28
votes
1 answer

SyntaxError: invalid token in datetime.datetime(2012,05,22,09,03,41)?

I do something like this: >>>import datetime >>>datetime.datetime(2012,05,22,05,03,41) datetime.datetime(2012, 5, 22, 5, 3, 41) >>> datetime.datetime(2012,05,22,07,03,41) datetime.datetime(2012,05,22,07,03,41) >>>…
user7172
  • 874
  • 4
  • 16
  • 31
28
votes
4 answers

How is local determined in ToLocalTime()

When using ToLocalTime(), how is local time determined? Is local time from the server or the client? My assumption would be the server running the application.
drobison
  • 858
  • 1
  • 14
  • 23
28
votes
17 answers

How to get a Long Date format from DateTime without a weekday

I'm looking for a locale-aware way of acquiring a long date time without the weekday. Just such a beast exist? Below is the code I use to get the long date format including the weekday: DateTime time = ... String formattedDate =…
Adam Tegen
  • 25,378
  • 33
  • 125
  • 153
28
votes
1 answer

Convert a unixtime to a datetime object and back again (pair of time conversion functions that are inverses)

I'm trying to write a pair of functions, dt and ut, that convert back and forth between normal unix time (seconds since 1970-01-01 00:00:00 UTC) and a Python datetime object. If dt and ut were proper inverses then this code would print the same…
dreeves
  • 26,430
  • 45
  • 154
  • 229
28
votes
3 answers

What type of column should I use for created_at and modified_at in Laravel Eloquent 2?

Should I use DATETEIME? or INT? Thanks! EDIT: I'm specifically addressing the public static $timestamps = true; flag set in Eloquent models.
brennanag
  • 583
  • 1
  • 5
  • 12
28
votes
5 answers

How do I get todays date one year ago in C#?

How do I get todays date one year ago in C#?
JL.
  • 78,954
  • 126
  • 311
  • 459
28
votes
4 answers

How to convert UTC datetime to another timezone?

How can i convert a date like this: 2012-07-16 01:00:00 +00 (it's in the UTC +00:00 timezone) to UTC +04:00 timezone? Ensuring that daylight saving will be handelled correctly?
Jo Smo
  • 6,923
  • 9
  • 47
  • 67
28
votes
4 answers

NSDateFormatter in 12-hour mode

I have the following code. NSDateFormatter *df = ...; [df setTimeZone:[NSTimeZone defaultTimeZone]]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"]; NSDate * date = [df dateFromString:date_string]; //here is the problem In 24-hour mode…
Sergey
  • 1,168
  • 2
  • 13
  • 28
28
votes
10 answers

Convert PHP date into javascript date format

I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function. My issue is I have a date within my array and it's not in the correct JavaScript format. How can I convert this within PHP so…
LeeTee
  • 6,401
  • 16
  • 79
  • 139
27
votes
5 answers

Specific Time Range Query in SQL Server

I'm trying to query a specific range of time: i.e. 3/1/2009 - 3/31/2009 between 6AM-10PM each day Tues/Wed/Thurs only I've seen that you can get data for a particular range, but only for start to end and this is quite a bit more specific. I…
Fry
  • 4,106
  • 9
  • 38
  • 51
27
votes
6 answers

Mocking The Time used by all instances of DateTime for testing purposes

I'd like to be able to set the time for every instance of DateTime instantiated for the duration of a PHPUnit or Behat Test. I'm testing business logic relating to time. For example that a method in a class only returns events in the past or…
Ben Waine
  • 1,650
  • 3
  • 21
  • 34
27
votes
8 answers

TeamCity Current Date variable in MMdd format

In TeamCity is there an easy way to get a variable for the current date in the format MMdd (eg 0811 for 8-Aug)? My google-fu did not turn up an existing plugins. I looked into writing a plugin, but not having a jdk installed, that looks time…
Robert Wagner
  • 17,515
  • 9
  • 56
  • 72
27
votes
8 answers

How to handle vague dates in .Net

I have a system that takes information from an external source and then stores it to be displayed later. One of the data items is a date. On the source system they have the concept of a fuzzy date i.e. not accurate to a specific day or sometimes not…
colethecoder
  • 1,139
  • 2
  • 8
  • 26
27
votes
2 answers

convert datetime64[ns, UTC] pandas column to datetime

I have a dataframe which has timestamp and its datatype is object. 0 2020-07-09T04:23:50.267Z 1 2020-07-09T11:21:55.536Z 2 2020-07-09T11:23:18.015Z 3 2020-07-09T04:03:28.581Z 4 2020-07-09T04:03:33.874Z Name: timestamp, dtype:…
merkle
  • 1,585
  • 4
  • 18
  • 33
27
votes
2 answers

OffsetDateTime to milliseconds

I want to know if there is a way to convert java.time.OffsetDateTime to Milliseconds, I found this way, but I don't know if it is the best one: book.getInteractionDuration().getStartTimeStamp().toEpochSecond()*1000
Sandro Rey
  • 2,429
  • 13
  • 36
  • 80
1 2 3
99
100