thehigherentity Posted October 19, 2006 Share Posted October 19, 2006 Im trying to find a way to convert dates that are stored in a database as E.G. 19760427 to 27/04/1976.I cant change how they are saved as this "19760427" format is needed for a different part of the code butI would like to be-able to display the date in this "27/04/1976" format too.Any ideas ?Its probaly simple but i have no idea....Thanks to anyone in advance that can help Link to comment https://forums.phpfreaks.com/topic/24493-how-can-i-change-this-date-19760427-to-this-27041976/ Share on other sites More sharing options...
kenrbnsn Posted October 19, 2006 Share Posted October 19, 2006 Use the functions [url=http://www.php.net/date]date()[/url] and [url=http://www.php.net/strtotime]strtotime()[/url]:[code]<?php echo date('d/m/Y',strtotime('19760427')); ?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/24493-how-can-i-change-this-date-19760427-to-this-27041976/#findComment-111562 Share on other sites More sharing options...
buildakicker Posted October 19, 2006 Share Posted October 19, 2006 You can also use MKTIME(). date("Y", mktime(......)); Link to comment https://forums.phpfreaks.com/topic/24493-how-can-i-change-this-date-19760427-to-this-27041976/#findComment-111564 Share on other sites More sharing options...
thehigherentity Posted October 19, 2006 Author Share Posted October 19, 2006 [quote author=kenrbnsn link=topic=112068.msg454672#msg454672 date=1161294114]Use the functions [url=http://www.php.net/date]date()[/url] and [url=http://www.php.net/strtotime]strtotime()[/url]:[code]<?php echo date('d/m/Y',strtotime('19760427')); ?>[/code]Ken[/quote]Thanks for that m8, I have been banging my head on the wall trying, I new it would be simple. Cant believe i never thought of the date function lol Link to comment https://forums.phpfreaks.com/topic/24493-how-can-i-change-this-date-19760427-to-this-27041976/#findComment-111594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.