Jump to content

[SOLVED] Add Days to a Date


yandoo

Recommended Posts

Hello

 

im a bit stuck again...

 

Any ideas on how can add a variable number of days (retrieved from database) to a date (also retrieved from database) to give a new date and then output the new date value????

 

 

e.g.  Both queries i have already retrieve and output the number of days and the SowDate.

 

84  2009-07-01

 

 

<?php echo $row_newtest['LifeTime'];?>
  <?php echo $row_test['SowDate']; ?>

 

 

I just need to add the days to the sowdate to give my new date...(which later is inserted a db.)

 

Any help would be be ace!

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/164856-solved-add-days-to-a-date/
Share on other sites

This is why you should work with unix timestamps in the database, and only show the dates in readable form when outputted to the browser.

 

Save your dates in the unix format, using php time(); for instance. Then add the number of seconds required, I.e.

 

86400 for one day.

604800 for one weak.

2629743 for one month.

31556926 for one year.

63113852 for two years.

Archived

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

×
×
  • Create New...

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.