marukochan Posted March 8, 2007 Share Posted March 8, 2007 Can anyone help me. I can't figure out why the date did not came out correctly. I wrote <?php $b = "2006-03-01"; print date("m/d/y",$b); ?> It suppose to come out as 01/Mar/06. But what what came out was 01/Jan/70. ??? Can anyone tell me why this happens. Link to comment https://forums.phpfreaks.com/topic/41748-something-wrong-with-date-format/ Share on other sites More sharing options...
tauchai83 Posted March 8, 2007 Share Posted March 8, 2007 why do want to print previous year date? $todaysDate=date("Y-m-d"); then use mktime php function to + or - to get the date you want. for example, $yesterday=date("Y-m-d",mktime(0,0,0,$month,$day-1,$year)); regards, chai Link to comment https://forums.phpfreaks.com/topic/41748-something-wrong-with-date-format/#findComment-202400 Share on other sites More sharing options...
vbnullchar Posted March 8, 2007 Share Posted March 8, 2007 Smaller code here! <? $b = "2006-03-01"; print date("m/d/y", strtotime($b)); ?> Link to comment https://forums.phpfreaks.com/topic/41748-something-wrong-with-date-format/#findComment-202406 Share on other sites More sharing options...
tauchai83 Posted March 8, 2007 Share Posted March 8, 2007 hehe..tat's easy but effective.. Link to comment https://forums.phpfreaks.com/topic/41748-something-wrong-with-date-format/#findComment-202537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.