Hi all. If I had a date string like this "20061231". Is there a built in functions to format this to something like "Sunday, December 31, 2006"
You could try:
<?php $date = "20061231"; echo date('l, F d, Y', strtotime($date)); ?>
Thanks laserlight. One last question. How can I tell if the string is a valid date? Happy New Year!
Use [man]checkdate/man by extracting the month, day and year:
function isValidDate($date) { return strlen($date) == 8 && checkdate(substr($date, 4, 2), substr($date, 6), substr($date, 0, 4)); }
Oh, and happy new year to you too!