PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
PHP Date adjustment (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: PHP Date adjustment
#886
edryan (User)
Junior Boarder
Posts: 21
graphgraph
User Offline Click here to see the profile of this user
PHP Date adjustment 3 Months, 1 Week ago Karma: 0  
hi,

i want to add a user-defined value to my date..

for example:

Today is September 30, 2008, and a user wants to add 15 days to the current date...so,

September 30, 2008 + 15 days = October 15, 2008

is there any way PHP can do that?

any help is appreciated..tnx
i would be glad if any script is available...
 
  The administrator has disabled public write access.
#887
kksou (Admin)
Admin
Posts: 443
graph
User Online Now Click here to see the profile of this user
Re:PHP Date adjustment 3 Months, 1 Week ago Karma: 8  
Hi,

This is a general PHP question, and not really PHP-GTK or Joomla specific, which this site is about.

In any case, you can use stototime(). For example:

Code:
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
For your case, most likely you will want to have the date in the proper format, so you might want to use:
Code:
<?php
$now = "September 30, 2008";
echo date('M d, Y', strtotime("$now +15 day"));
?>
    You can see more information in the PHP official documentation
      Regards,
        /kksou
         
         
        Last Edit: 2008/09/29 13:25 By kksou.
          The administrator has disabled public write access.
        Go to top Post Reply
        Powered by FireBoardget the latest posts directly to your desktop

        Blog - Forum - Privacy Policy - Contact Us
        Copyright © 2006-2009. kksou.com. All Rights Reserved