News & Blog

How to Sort an Array by Date using PHP

May 24th, 2014 - Posted by Steve Marks to PHP, Web Development.
Recently I was working on a date-based script that needed to obtain a list of items and sort them by date. In my scenario it was a list of files and I needed to arrange them by their last modified date. The first prerequisite is that the key part of the array contains the date [...]...

JavaScript new Date() Returning NaN in IE or Invalid Date in Safari

February 8th, 2011 - Posted by Steve Marks to Javascript / jQuery, Web Development.
When it comes to programming, working with dates can be tricky. Luckily however most languages have done the hard work already and come with some kind of built-in date functionality to assist us. JavaScript inparticular has lots of useful functions to aid in getting, setting and outputting...

PHP date() Function Showing Date from 1970

December 30th, 2010 - Posted by Steve Marks to PHP, Web Development.
I’ve lost count of the amount of times I’ve used the PHP date() function and wondered why it’s returning a date from 1970 so I wanted to share with you the most common reason/mistake I’ve found for causing this in the event that you are facing the same problem. The ...

Get the Current Season Using PHP

October 4th, 2010 - Posted by Steve Marks to PHP, Web Development.
The PHP date() function is great for the majority of tasks regarding getting a date or time, however one thing it doesn’t cater for is obtaining the season. Seasons generally vary depending on the year and where you’re based in the world; While it’s Summer in the Northern...

Get a List of Dates Between Two Dates with PHP

October 3rd, 2010 - Posted by Steve Marks to PHP, Web Development.
When building an events calendar recently I needed to obtain all the dates between two dates. For others looking to do the same thing I used the code below to achieve this. Simply change the $date_from and $date_to variables to get it working for you. // Specify the start date. This date c...