Go Back   CP Web Hosting - reseller hosting > Server Scripting > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 10:01 AM
Senior Member
 
Join Date: May 2007
Posts: 217
Default PHP code help

I use:
$today = date("F - j - Y");

however I want to add a certain number of days to it.
Like: $nextweek = 7

How can I add those 7 days to the current date? and still keep it in the same format.
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 10:04 AM
Senior Member
 
Join Date: Mar 2007
Posts: 193
Default

Quote:
Originally Posted by tertius View Post
I use:
$today = date("F - j - Y");

however I want to add a certain number of days to it.
Like: $nextweek = 7

How can I add those 7 days to the current date? and still keep it in the same format.
this function u can use with MySQL database

Code:
function dt_only_date_minus_x_days( $x ) {
  return date("Y-m-d", time( ) - ( $x * 24 * 60 * 60 ) );
}

function dt_minus_x_days( $x ) {
  return date("Y-m-d G:i:s", time( ) - ( $x * 24 * 60 * 60 ) );
}

function dt_now( ) {
  return dt_minus_x_days( 0 );
}

function dt_yesterday( ) {
  return dt_minus_x_days( 1 );
}
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 10:05 AM
Senior Member
 
Join Date: Apr 2007
Posts: 347
Default

Try his one

Code:
$time = time() + (7 * 24 * 60 * 60);
print $today = date("F - j - Y");              # today
print $today = date("F - j - Y", $time);    # next week
Reply With Quote
  #4 (permalink)  
Old 06-28-2007, 10:11 AM
Senior Member
 
Join Date: Apr 2007
Posts: 311
Default

I think this will be useful for u

Code:
date("F - j - Y", strtotime('+1 week'));
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:58 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0