Deoctor Posted February 5, 2010 Share Posted February 5, 2010 How do i convert date of this format Friday 5th of February 2010 10:54:01 AM to something like this 02/05/2010 Quote Link to comment Share on other sites More sharing options...
Irvin Amoraal Posted February 5, 2010 Share Posted February 5, 2010 Need more information. How/where do you get the date? What are you using it for. Look at the php manual for date strings: http://php.net/manual/en/function.date.php Also found this Googling php date format: <?PHP if (!function_exists('convertTime')) { /** Converts time strings from one format into another using * PHP formats. * * @param String $dformat Format to convert to * @param String $sformat Format to convert from, e.g. format * of $ts * @param String $ts Time string to be converted * @return String Supplied time translated to the format specified * in $dformat */ function convertTime($dformat,$sformat,$ts) { extract(strptime($ts,$sformat)); return strftime($dformat,mktime( intval($tm_hour), intval($tm_min), intval($tm_sec), intval($tm_mon)+1, intval($tm_mday), intval($tm_year)+1900 )); } } /* * And for the test.... */ echo convertTime('%Y-%m-%d','%d.%m.%Y','27.11.2009'); ?> This should print "2009-27-11". Hope this helps. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted February 5, 2010 Author Share Posted February 5, 2010 Dear Irvon ur function does not work.. as strptime is not a valid php function. and for the info u require i am getting the date value as like this.. date('l jS \of F Y h:i:s A') i have checked the php manual but didnt found any solution for my issue. :'( Can some one help me out on this.. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 5, 2010 Share Posted February 5, 2010 <?php $indate = 'Friday 5th of February 2010 10:54:01 AM'; $datebits = explode(" ",$indate); $indate2 = (int)$datebits[1].' '.$datebits[3].' '.$datebits[4]; echo strftime("%m/%d/%Y",strtotime($indate2)); ?> Quote Link to comment Share on other sites More sharing options...
Deoctor Posted February 5, 2010 Author Share Posted February 5, 2010 Cool reply thank you dude.. Quote Link to comment Share on other sites More sharing options...
Irvin Amoraal Posted February 5, 2010 Share Posted February 5, 2010 Try one of these: <?php echo date("Y/m/d") . "<br />"; echo date("Y.m.d") . "<br />"; echo date("Y-m-d") ?> Irvin. <>< Quote Link to comment 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.