• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

Subtracting and adding to current date then turn into timestamp

Hi all,

I have to take the current time and date, and I have to add it 9 hours and subtract 3 minutes and also subtract 7 seconds.
Then I have to turn the result into a timestamp.

For example, let's say that the current time is 10 hours 3 minutes and 7 seconds and the date is today's date.
I need it to be 19 hours 0 minutes and 0 seconds of today's date and I have to turn that into a timestamp.

How can I do it?
Thanks a ton in advance!
0
Dada44
Asked:
Dada44
  • 2
  • 2
1 Solution
 
Michael701Commented:
why try all math before converting?

$answer = time() + 9 * 3600 - 3 * 60 - 7;
0
 
Dada44Author Commented:
sorry but converting the timestamp I get is: Thu, 23 Apr 2009 03:02:36 +0200
and it should be  Thu, 22 Apr 2009 18:03:36 +0200
0
 
Michael701Commented:
Do you need local (server) time? GMT? or Clients time?


$answer = time();
echo "Now : ". date("M j G:i:s T Y", $answer) ."<br />\n";
$answer = $answer + 9 * 3600 - 3 * 60 - 7;
echo "Then: ". date("M j G:i:s T Y", $answer) ."<br />\n";
 
(output)
 
Now : Apr 22 9:21:54 MST 2009
Then: Apr 22 18:18:47 MST 2009

Open in new window

0
 
Dada44Author Commented:
thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now