current date + 7 days

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
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

current date + 7 days

Post by AshrakTheWhite »

how do i do that?

using timestamps and mktime i can get the unix timestamp for 7 days from now, but how do i reformat it back to d.m.y format?


what i need this for is to have the date of entry incremented by 7 aka a week and apparently date('d.m.y') dosent let me just add 7 to the days, and i dont know how to convert out of unix timestamp into normal date format.


Thanx for help!
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: current date + 7 days

Post by aerodromoi »

AshrakTheWhite wrote:how do i do that?

using timestamps and mktime i can get the unix timestamp for 7 days from now, but how do i reformat it back to d.m.y format?


what i need this for is to have the date of entry incremented by 7 aka a week and apparently date('d.m.y') dosent let me just add 7 to the days, and i dont know how to convert out of unix timestamp into normal date format.


Thanx for help!

Code: Select all

$newstamp = date("d.m.Y",$yourmodifiedtimestamp);
aerodromoi
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Usually i find http://www.php.net/strtotime easier than mktime ;)

Code: Select all

<?php
echo date('d.m.Y', strtotime('+7 days'));
?>
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post by aerodromoi »

timvw wrote:Usually i find http://www.php.net/strtotime easier than mktime ;)

Code: Select all

<?php
echo date('d.m.Y', strtotime('+7 days'));
?>
Each to their own, I suppose.
I usually work with timestamps and convert them only for the actual output. And 604800 isn't too bad ,)

aerodromoi
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

both of those output unix timestamps, what i need is the opposite, i need a non unix time out of an unix timestamp
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post by aerodromoi »

AshrakTheWhite wrote:both of those output unix timestamps, what i need is the opposite, i need a non unix time out of an unix timestamp
I wouldn't say that...

Code: Select all

<?php
$yourmodifiedtimestamp= date("U") + 604800;
echo date("d.m.Y",$yourmodifiedtimestamp);
?>
aerodromoi
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Post by AshrakTheWhite »

try before you judge :oops: , sorry for the agony :p

works perfect cheers :)
Post Reply