psychohagis Posted March 27, 2007 Share Posted March 27, 2007 I want to convert a date in the format (dd/mm/yyyy) into a time() style format so I can compare it against the current time and only use information where its date is ahead of the current time. Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/ Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 http://us2.php.net/manual/en/function.date.php $newDate = date("d/m/Y", $time); my mistake you wanted it the other way. I think this is what you want: http://us2.php.net/manual/en/function.strtotime.php Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/#findComment-216192 Share on other sites More sharing options...
psychohagis Posted March 27, 2007 Author Share Posted March 27, 2007 Does anyone have anymore knowledge on this because I have explored the function mentioned above but I have on problem. According to the manual it will convert any english date into a time() type format. but thats not quite true. In england dd/mm/yyyy is standard but if you put in a date that is formatted like that it assumes it is mm/dd/yyyy which is the american format. Is their anyway I can tell strtotime() that its dd/mm/yyyy instead of mm/dd/yyyy ?? thanks in advance Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/#findComment-216265 Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 If you explode the date you can use the mktime() function. http://us2.php.net/mktime //int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] ) list($day,$month,$year) = explode("/", $date); $unixTime = mktime(0,0,0,$month,$day,$year); Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/#findComment-216271 Share on other sites More sharing options...
psychohagis Posted March 27, 2007 Author Share Posted March 27, 2007 ah that works perfectly thanks Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/#findComment-216296 Share on other sites More sharing options...
Curveo Posted June 26, 2008 Share Posted June 26, 2008 i just thought I would mention that another thing you could do is parse the date into an array using the date_parse() method. I was looking for a way to reformat a MYSQL timestamp string and this (date_parse($row["date"]) worked perfectly. Link to comment https://forums.phpfreaks.com/topic/44518-solved-converting-a-date-format-ddmmyyyy-into-a-time-format/#findComment-574753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.