Reply to Re: date arithmetic

Your name:

Reply:


Posted by NC on 12/07/06 03:39

wesley@ispace.co.za wrote:
>
> I have tried to use some of the functions you guys suggested.
> Some work fine but others like strtotime return results that i dont
> think are correct: This is what i have tried:
>
> echo strtotime('+ 1 month');
> The result is 1168074894

And why is it not correct? 1168074894 is the Unix time stamp for
some time on January 6, 2007... Have you read the PHP
documentation at all? If you did, you'd know that strtotime() returns
a timestamp and you will need to call date() to format a date
represented by that timestamp, like so:

echo date('Y-m-d', strtotime('+ 1 month'));

For more information, see:

http://www.php.net/strtotime
http://www.php.net/date

> I have also found another function to modify the date:
>
> $date = new DateTime("2006-12-12");
> $date->modify("+1 day");
> echo $date->format("Y-m-d");
>
> But this returns nothing. "DateTime" is not being recorgnized.

But of course it isn't. You try to refer to a class called DateTime;
as far as I can tell, this is not something that ships with PHP.
So you need to find out where this class came from and include()
the appropriate files...

> This function is supposed to be supported.

I don't think so. Not to mention the fact this is not a function,
but a class...

Cheers,
NC

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация