note 38184 added to function.strtotime

From: Date: Thu, 11 Dec 2003 09:28:51 +0000
Subject: note 38184 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-61784@lists.php.net to get a copy of this message
Here is a simple function for those (like me) who use different notation of a date. A date 1981-06-26 in Poland (I don't know if it's used in other countries of Europe) should be written 26-06-1981. So this function just converts date to timestamp so you can safely compare dates or use getdate() to extract month, day etc. Just pass a string with a date with month, day and year separated with "-" (still you can change it to other characters) function StrToTimestamp($str) { $date = explode("-",$str); //swaps places of year and day return strtotime($date[2]."-".$date[1]."-".$date[0]); } ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38184 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38184&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38184&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61784) next »