cooldude832 Posted October 11, 2007 Share Posted October 11, 2007 I got a number like $day = 08; and I want it to be $day = 8; however day could also be $day = 19; and I don't just want to auto strip that any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/ Share on other sites More sharing options...
thedarkwinter Posted October 11, 2007 Share Posted October 11, 2007 try: $day = intval($day); should do the trick. cheers, tdw Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367136 Share on other sites More sharing options...
cooldude832 Posted October 11, 2007 Author Share Posted October 11, 2007 I did this <?php if(strpos($date_data[2],0) == 0){ $tday = substr($date_data[2],1,1); } else{ $tday = $date_data[2]; } ?> where $date_data[2] is that day nubmer in question. Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367137 Share on other sites More sharing options...
MadTechie Posted October 11, 2007 Share Posted October 11, 2007 erm.. no use $day =(int) $day; Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367138 Share on other sites More sharing options...
cooldude832 Posted October 11, 2007 Author Share Posted October 11, 2007 I solved that issue, but now i'm using the date function and usnig the indentiacl mktime field getting 2 different dates <?php $date = date("l nS \of F Y",mktime(0,0,0,$date_data[1],$date_data[2],$date_data[0])); $date2 = date("M-d-Y",mktime(0,0,0,$date_data[1],$date_data[2],$date_data[0])); ?> Date 1: Saturday 6th of June 2002 Date 2: Jun-08-2002 How can this be they are the same identical mktime() ??? Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367153 Share on other sites More sharing options...
thedarkwinter Posted October 11, 2007 Share Posted October 11, 2007 date("l nS \of F Y") n = month number use d instead Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367173 Share on other sites More sharing options...
thedarkwinter Posted October 11, 2007 Share Posted October 11, 2007 or "j" rather for no leading zeros Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367174 Share on other sites More sharing options...
MadTechie Posted October 11, 2007 Share Posted October 11, 2007 can you print_r($date_data); a common problems is having the 5th param as a zero, which refers to, todays day.. Quote Link to comment https://forums.phpfreaks.com/topic/72798-stripping-left-ended-zeros-off-a-number/#findComment-367176 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.