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.
datetime
8,437
questions
234
votes
3
answers
42k
views
How to use ThreeTenABP in Android Project
I'm using Android Studio 2.1.2 and my Java setup is the following:
>java -version
> openjdk version "1.8.0_91"
> OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10....
388
votes
18
answers
706k
views
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); // ...
2802
votes
48
answers
3.4m
views
Compare two dates with JavaScript
Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.
824
votes
33
answers
1.1m
views
How to calculate the difference between two dates using PHP?
I have two dates of the form:
Start Date: 2007-03-24
End Date: 2009-06-26
Now I need to find the difference between these two in the following form:
2 years, 3 months and 2 days
How can I do this ...
2971
votes
26
answers
4.6m
views
Convert string "Jun 1 2005 1:33PM" into datetime
I have a huge list of datetime strings like the following
["Jun 1 2005 1:33PM", "Aug 28 1999 12:00AM"]
How do I convert them into datetime objects?
1655
votes
40
answers
671k
views
Determine Whether Two Date Ranges Overlap
Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap?
As an example, suppose we have ranges denoted by DateTime variables StartDate1 to ...
2200
votes
30
answers
495k
views
Daylight saving time and time zone best practices [closed]
I am hoping to make this question and the answers to it the definitive guide to dealing with daylight saving time, in particular for dealing with the actual change overs.
If you have anything to add,...
934
votes
28
answers
752k
views
How do I parse an ISO 8601-formatted date and time?
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is ...
1284
votes
25
answers
1.6m
views
How to sort an object array by date property?
Say I have an array of a few objects:
var array = [{id: 1, date: Mar 12 2012 10:00:00 AM}, {id: 2, date: Mar 8 2012 08:00:00 AM}];
How can I sort this array by the date element in order from the date ...
179
votes
4
answers
60k
views
Ignoring time zones for Postgres timestamps
I'm dealing with dates and times in Rails and Postgres and running into this issue:
The database is in UTC.
The user sets a time zone of choice in the Rails app, but it's only to be used when getting ...
125
votes
5
answers
36k
views
What's wrong with Java Date & Time API? [closed]
Very often I come across negative feedback on Java Date and other date-time-related classes. Being a .NET developer, I cannot fully (without having used them) understand, what's actually wrong with ...
643
votes
30
answers
1.8m
views
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 @...
488
votes
7
answers
1.2m
views
Convert Pandas Column to DateTime
I have one field in a pandas DataFrame that was imported as string format.
It should be a datetime variable. How do I convert it to a datetime column, and then filter based on date?
Example:
raw_data =...
2256
votes
75
answers
836k
views
How do I calculate someone's age based on a DateTime type birthday?
Given a DateTime representing a person's birthday, how do I calculate their age in years?
244
votes
9
answers
945k
views
How to change the datetime format in Pandas
My dataframe has a DOB column (example format 1/1/2016) which by default gets converted to Pandas dtype 'object'.
Converting this to date format with df['DOB'] = pd.to_datetime(df['DOB']), the date ...