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 , 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 an 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.

60897 questions
650
votes
16 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
614
votes
15 answers

Get current time in milliseconds in Python?

How can I get the current time in milliseconds in Python?
Naftuli Kay
  • 75,812
  • 80
  • 244
  • 374
611
votes
14 answers

How to make a timezone aware datetime object in Python?

What I need to do I have a timezone-unaware datetime object, to which I need to add a time zone in order to be able to compare it with other timezone-aware datetime objects. I do not want to convert my entire application to timezone unaware for…
Mark Tozzi
  • 8,455
  • 4
  • 20
  • 30
569
votes
29 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
  • 36,412
  • 47
  • 153
  • 230
544
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,093
  • 3
  • 18
  • 15
531
votes
13 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
  • 53,561
  • 13
  • 87
  • 108
529
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
  • 14,304
  • 11
  • 46
  • 58
528
votes
40 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
  • 6,311
  • 5
  • 32
  • 48
523
votes
7 answers

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why?
flybywire
  • 232,954
  • 184
  • 384
  • 491
518
votes
20 answers

NOW() function in PHP

Is there a PHP function that returns the date and time in the same format as the MySQL function NOW()? I know how to do it using date(), but I am asking if there is a function only for this. For example, to return: 2009-12-01 00:00:00
MoeAmine
  • 5,476
  • 2
  • 15
  • 20
512
votes
33 answers

How can I get the DateTime for the start of the week?

How do I find the start of the week (both Sunday and Monday) knowing just the current time in C#? Something like: DateTime.Now.StartWeek(Monday);
GateKiller
  • 68,419
  • 71
  • 167
  • 203
501
votes
18 answers

Incrementing a date in JavaScript

I need to increment a date value by one day in JavaScript. For example, I have a date value 2010-09-11 and I need to store the date of the next day in a JavaScript variable. How can I increment a date by a day?
Santanu
  • 6,816
  • 7
  • 22
  • 23
499
votes
12 answers

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

I'm using: str(datetime.datetime.today()).split()[0] to return today's date in the YYYY-MM-DD format. Is there a less crude way to achieve this?
Pyderman
  • 10,029
  • 9
  • 46
  • 85
493
votes
5 answers

What is the significance of 1/1/1753 in SQL Server?

Why 1753? What do they have against 1752? My great great great great great great great grandfather would be very offended.
Daniel
  • 6,068
  • 6
  • 29
  • 29
483
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
  • 67,994
  • 42
  • 125
  • 155