darkfreaks Posted January 17, 2009 Share Posted January 17, 2009 Warning: mktime() expects parameter 1 to be long, string given any help would be appreciated ??? Code: <?php function formatDate($val) { list($date, $time) = explode(" ", $val); list($year, $month, $day) = explode("-", $date); list($hour, $minute, $second) = explode (":", $time); return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));//error line } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141168-time-question/ Share on other sites More sharing options...
RussellReal Posted January 17, 2009 Share Posted January 17, 2009 this is pushing a datatype related error, php handles datatype conversions as you attempt to convert them.. you could fix this by converting them into themselves but their numeric equivelent to the string versions return date("l, m.j.y @ H:ia", mktime(($hour * 1), ($minute * 1), ($second * 1), ($month * 1), ($day * 1), ($year * 1)));//error line Quote Link to comment https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738889 Share on other sites More sharing options...
darkfreaks Posted January 17, 2009 Author Share Posted January 17, 2009 ok so i switched to time() now it returns: 1.17.09 instead of: 17.01.09 Quote Link to comment https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738891 Share on other sites More sharing options...
PFMaBiSmAd Posted January 17, 2009 Share Posted January 17, 2009 What format is $val and where is it coming from? Quote Link to comment https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738897 Share on other sites More sharing options...
RussellReal Posted January 17, 2009 Share Posted January 17, 2009 I just re-read your post, however, my script SHOULD work; you could just use strtotime() on your currently formatted date string, and that wioll return a unix timestamp for which you can use date() with in order to [re-]format your date Quote Link to comment https://forums.phpfreaks.com/topic/141168-time-question/#findComment-738898 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.