All Questions

236
votes
12answers
333735 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); // re...
1244
votes
34answers
1353940 views

Where can I find documentation on formatting a date in JavaScript?

I noticed that JavaScript's new Date() function is very smart in accepting dates in several formats. Xmas95 = new Date("25 Dec, 1995 23:15:00") Xmas95 = new Date("2009 06 12,12:52:39") Xmas95 = new D...
614
votes
31answers
642149 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 th...
1204
votes
35answers
1182789 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...
1807
votes
29answers
329435 views

Daylight saving time and time zone best practices

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...
902
votes
32answers
270403 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 E...
1245
votes
17answers
1469123 views

Converting string into datetime

Short and simple. I've got a huge list of date-times like this as strings: Jun 1 2005 1:33PM Aug 28 1999 12:00AM I'm going to be shoving these back into proper datetime fields in a database so I n...
129
votes
2answers
25986 views

Ignoring timezones altogether in Rails and PostgreSQL

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 gettin...
73
votes
5answers
19428 views

What's wrong with Java Date & Time API?

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 th...
1264
votes
34answers
128230 views

Calculate relative time in C#

Given a specific DateTime value, how do I display relative time, like: 2 hours ago 3 days ago a month ago

Previous Next