Make date("s"); 30 in the future?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Make date("s"); 30 in the future?

Post by Dale »

I do this

Code: Select all

<?php
$a1 = date("s");
$b2 = 30;
$c3 = $a1 + $b2;
print $c3;
?>
However when its 56 seconds past the minute the future seconds ($c3) shows 86... but i want it to show it as 26... please help :)

tags don't work :([/b]
Last edited by Dale on Mon Jan 31, 2005 10:05 am, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

$newtime = time() + 30;
It is always better to use unix time stamps as they are more portable for a variety of thigns, as you can see :P... Just use the date function now to display it according.
Last edited by John Cartwright on Mon Jan 31, 2005 9:05 am, edited 1 time in total.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

So i dont have to add the "s" ?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I'm a bit confused on what your saying, notice in my example I use the
time() function and you used to the date() function to get the time.
Read my previous post as I updated it.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Ohhh... I get it :)

Thanks!
hunterhp
Forum Commoner
Posts: 46
Joined: Sat Jan 22, 2005 5:20 pm
Contact:

Post by hunterhp »

Dale wrote:Ohhh... I get it :)

Thanks!
How come you didn't follow your own sig's advice?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

hunterhp wrote:
Dale wrote:Ohhh... I get it :)

Thanks!
How come you didn't follow your own sig's advice?
tags dont work anymore...
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

ok, question 2... how do i change the time(); value (eg; 1107186914) to a date(); value? (eg; h:i:s)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

echo date("F j, Y, g:i a", $value)

Code: Select all

http://uk.php.net/manual/en/function.date.php
Post Reply