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
595
votes
21 answers

How to add hours to a Date object?

It amazes me that JavaScript's Date object does not implement an add function of any kind. I simply want a function that can do this: var now = Date.now(); var fourHoursLater = now.addHours(4); function Date.prototype.addHours(h) { // How do I…
Jeff Meatball Yang
  • 37,839
  • 27
  • 91
  • 125
587
votes
48 answers

How do I calculate the date six months from the current date using the datetime Python module?

I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this? The reason I want to generate a date 6 months from the current date is to produce a review…
RailsSon
  • 19,897
  • 31
  • 82
  • 105
584
votes
23 answers

Creating a range of dates in Python

I want to create a list of dates, starting with today, and going back an arbitrary number of days, say, in my example 100 days. Is there a better way to do it than this? import datetime a = datetime.datetime.today() numdays = 100 dateList = [] for…
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121
578
votes
34 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
  • 74,180
  • 73
  • 171
  • 204
574
votes
12 answers

Algorithm to detect overlapping periods

I've to detect if two time periods are overlapping. Every period has a start date and an end date. I need to detect if my first time period (A) is overlapping with another one(B/C). In my case, if the start of B is equal to the end of A, they are…
J4N
  • 19,480
  • 39
  • 187
  • 340
569
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,976
  • 2
  • 18
  • 21
566
votes
21 answers

How do I find the time difference between two datetime objects in python?

How do I tell the time difference in minutes between two datetime objects?
Hobhouse
  • 15,463
  • 12
  • 35
  • 43
556
votes
7 answers

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why?
flybywire
  • 261,858
  • 191
  • 397
  • 503
554
votes
20 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
  • 7,764
  • 7
  • 26
  • 24
552
votes
16 answers

Python datetime to string without microsecond component

I'm adding UTC time strings to Bitbucket API responses that currently only contain Amsterdam (!) time strings. For consistency with the UTC time strings returned elsewhere, the desired format is 2011-11-03 11:07:04 (followed by +00:00, but that's…
davidchambers
  • 23,918
  • 16
  • 76
  • 105
552
votes
17 answers

Find objects between two dates MongoDB

I've been playing around storing tweets inside mongodb, each object looks like this: { "_id" : ObjectId("4c02c58de500fe1be1000005"), "contributors" : null, "text" : "Hello world", "user" : { "following" : null, "followers_count" : 5, …
Tom
  • 33,626
  • 31
  • 85
  • 109
541
votes
6 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,758
  • 6
  • 31
  • 29
537
votes
25 answers

Iterating through a range of dates in Python

I have the following code to do this, but how can I do it better? Right now I think it's better than nested loops, but it starts to get Perl-one-linerish when you have a generator in a list comprehension. day_count = (end_date - start_date).days +…
ShawnMilo
  • 5,896
  • 3
  • 19
  • 15
531
votes
9 answers

Moment js date time comparison

I'm using moment.js to format my date time, here I have two date values, and I want to achieve a particular function when one date is greater than the other. I read most of their docs, but didn't find the function to achieve this. I know it will be…
Dibish
  • 9,133
  • 22
  • 64
  • 106
527
votes
4 answers

What's the difference between Instant and LocalDateTime?

I know that: Instant is rather a "technical" timestamp representation (nanoseconds) for computing. LocalDateTime is rather date/clock representation including time-zones for humans. Still in the end IMO both can be taken as types for most…
manuel aldana
  • 15,650
  • 9
  • 43
  • 50