Jump to content

Archived

This topic is now archived and is closed to further replies.

tjhilder

[solved] add time() to date() with $row ?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.