...

View Full Version : date



Mihai
03-11-2008, 02:28 AM
is it possible to change the date to show 1224 today and start counting ?

<?php
$date = new DateTime("2008-03-10");
$date->modify("-384 Year");
echo $date->format("Y-m-d");
?>

:D

Mihai
03-11-2008, 02:32 AM
<?php
$currentDate = new DateTime('2008-03-10');
$endDate = new DateTime('1224-03-10');

while($currentDate < $endDate) {
echo $currentDate -> format('Y-m-d') . ' till ';
$currentDate -> modify('+784 Years');
echo $currentDate -> format('Y-m-d') . ' <br />';
}
?>
this will work ?

Mihai
03-11-2008, 03:08 AM
noone knows ?

oesxyl
03-11-2008, 03:38 AM
this will work ?
did you test it?

- you must close the code between [ php] and [ /php] tags.
- remove the space before and after, ->
- $currentDate is after $endDate, so any < have no sense
- I don't know if operator < work for DateTime objects

try this:


<?php
$currentDate = new DateTime('2008-03-10');
$endDate = new DateTime('1224-03-10');

// while($currentDate < $endDate) {
echo $currentDate->format('Y-m-d') . ' till ';
$currentDate->modify('+784 Years');
echo $currentDate->format('Y-m-d') . ' <br />';
// }
?>


best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum