Archive for the ‘PHP’ Category

How to compare two dates in php

Posted on December 6th, 2009 by admin
Filed under PHP, Tutorials | No Comments

Now that we know how to convert a formatted date in PHP to timestamp. Let’s move on to compare two dates. At my workplace I came across and instance where I had to check the posted date wasn’t less than today’s date, so let’s put this in picture so you know the concept behind date [...]

How to convert a date into a timestamp

Posted on December 5th, 2009 by admin
Filed under PHP, Tutorials | 1 Comment

Whether you are posting a date or a passing variable that is a formatted date you can use the function below to convert it into a timestamp function convert_timestamp($delimeter,$date){ $explode_date = explode($delimeter,$date); $new_date = mktime(0,0,0,$explode_date[1],$explode_date[0],$explode_date[2]); return $new_date; } Now to test the function we have created is shown below. $date = “01/12/2009″; $delimeter = “/”; [...]