Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Sbtract time from date

Question posted by: ghjk (Member) on May 15th, 2008 06:59 AM
I want to subtract three hours from current time. How can i do that?
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Atli's Avatar
Atli
Moderator
2,028 Posts
May 15th, 2008
07:20 AM
#2

Re: Sbtract time from date
That depends.
Can be as simple as:
Code: ( text )
  1. $newDate = date("H:i:s", time() - (3600 * 3));

If this is not what you need, please explain in greater detail, and show us the code you are using.

Reply
ghjk's Avatar
ghjk
Member
111 Posts
May 15th, 2008
09:33 AM
#3

Re: Sbtract time from date
Quote:
Originally Posted by Atli
That depends.
Can be as simple as:
Code: ( text )
  1. $newDate = date("H:i:s", time() - (3600 * 3));

If this is not what you need, please explain in greater detail, and show us the code you are using.



Thank you so much.It is working. But i want to subtract from current time with date.
Eg: 2008-05-15 15:03-(3 hours)
Could you please tell me how can i do that?

Reply
ghjk's Avatar
ghjk
Member
111 Posts
May 15th, 2008
09:36 AM
#4

Re: Sbtract time from date
I have done it. Again thank you Atli.
Code: ( text )
  1. $newDate = date("Y-m-d H:i:s", time() - (3600 * 3));
  2. echo "$newDate";

Reply
Reply
Not the answer you were looking for? Post your question . . .
178,097 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top PHP Forum Contributors