vj5 Posted February 15, 2008 Share Posted February 15, 2008 How do I convert date from 02/15/2008 to Febraury 15th, 2008 in PHP? The variable I am using is cdate. Any help?????Thanks in advance. Link to comment Share on other sites More sharing options...
zppblood Posted February 15, 2008 Share Posted February 15, 2008 How do I convert date from 02/15/2008 to Febraury 15th, 2008 in PHP? The variable I am using is cdate. Any help?????Thanks in advance. <?php $date=explode('/', '02/15/08'); echo date('F dS, Y', mktime(0, 0, 0, $date[0], $date[1], $date[2]));?> Link to comment Share on other sites More sharing options...
vj5 Posted February 17, 2008 Author Share Posted February 17, 2008 <?php $date=explode('/', '02/15/08'); echo date('F dS, Y', mktime(0, 0, 0, $date[0], $date[1], $date[2]));?> Actually, I don't want to give specific dates like 02/15/08, I gave that for example. All dates are stored in the variable $cdate as 02/15/08 format. So can I replace $cdate in the place where the date such as:<?php $date=explode('/', '$cdate'); echo date('F dS, Y', mktime(0, 0, 0, $date[0], $date[1], $date[2]));?> Link to comment Share on other sites More sharing options...
Synook Posted February 17, 2008 Share Posted February 17, 2008 Yes (btw, you don't need quotes around $cdate). Link to comment Share on other sites More sharing options...
vj5 Posted February 17, 2008 Author Share Posted February 17, 2008 Yes (btw, you don't need quotes around $cdate).Thank you. Link to comment Share on other sites More sharing options...
zppblood Posted February 17, 2008 Share Posted February 17, 2008 Never put ' around variables because PHP will think you want to use the string $cdate instead of the value you intended to use. Link to comment Share on other sites More sharing options...
vj5 Posted February 17, 2008 Author Share Posted February 17, 2008 Never put ' around variables because PHP will think you want to use the string $cdate instead of the value you intended to use.Thanks for the code. Link to comment Share on other sites More sharing options...
Synook Posted February 17, 2008 Share Posted February 17, 2008 ' are literal quotes, while " are ... not so literal e.g. $var = "This is a variable";echo '$var'; //Will echo "$var"echo "$var"; //Will echo "This is a variable" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.