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. Link to comment https://forums.phpfreaks.com/topic/20878-solved-add-time-to-date-with-row/ 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 Link to comment https://forums.phpfreaks.com/topic/20878-solved-add-time-to-date-with-row/#findComment-92574 Share on other sites More sharing options...
tjhilder Posted September 16, 2006 Author Share Posted September 16, 2006 thanks, that solves my problem :) Link to comment https://forums.phpfreaks.com/topic/20878-solved-add-time-to-date-with-row/#findComment-92962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.