tjhilder Posted September 15, 2006 Share Posted September 15, 2006 Hi,I dunno if that title makes any sense... basicly I have this:[code]$month = date("m", $row['a_dfrom']);[/code]but I want to take away 1 from it, doing -1 like..[code]$month = date("m", $row['a_dfrom'])-1;[/code]this seems to transfer any thing like 01 - 09 to 1 - 9 so when php checks to see if 08 is 08 it comes up 8 is 08.is there any way of fixing this?thanks in advance. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 15, 2006 Share Posted September 15, 2006 When you subtract one, PHP changed the string to an integer, so it doesn't have a leading zero.Try this:[code]<?php$month = sprintf("%02d",date("m", $row['a_dfrom'])-1);?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
tjhilder Posted September 16, 2006 Author Share Posted September 16, 2006 thanks, that solves my problem :) Quote Link to comment 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.