oskare100 Posted January 20, 2007 Share Posted January 20, 2007 Hello,When the scripts requests from the Ebay API it need to supply the current time and date plus five days and minus five days. It needs to be in this format: 2007-01-17T18:28:52.799ZSo if now is 2007-01-20 18:28:52 then I need he script to create two variables with the following values;(Minus five days) $time_from = 2007-01-15T18:28:52.799Z (Plus five days) $time_to: = 2007-01-25T18:28:52.799Z How can I make PHP add minus five days to, for example, $time_from and plus five days to, for example, $time_to as above?Thanks in advance,/Oskar R Quote Link to comment Share on other sites More sharing options...
trochia Posted January 20, 2007 Share Posted January 20, 2007 60*60*24*5 = ?? :-) Quote Link to comment Share on other sites More sharing options...
jumpenjuhosaphat Posted January 20, 2007 Share Posted January 20, 2007 It'd probably be easiest to use the unix time stamp format returned by the time() function, and store that in the variables, and then using the date() function to restore it to a readable format however you want it displayed.Unix timestamp is the amount of time in seconds that have gone by since January 1, 1970. So to get the timestamp from 5 days ago, you would subtract 60*60*24*5 from the current time, and to get the timestamp for 5 days in the future, you would add this.[code]$current=time();$fiveago=time()-(60*60*24*5);$fiveahead=time()+(60*60*24*5);[/code]Then to retrieve the values you would use the date function[code]echo date("M jS, Y", $fiveago);echo date("M jS, Y", $fiveahead);[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.