473,378 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to add several days to the current date using php?

how to add several days to the current date using php? here my php code

[PHP]$time = gmdate('Y-m-d H:i:s a');[/PHP]

what i mean is i want to add 2 days on the current date. how can i do this? your help are appreciate! thanks...

regard Fareast Adam
Sep 23 '07 #1
5 9163
realin
254 100+
how to add several days to the current date using php? here my php code

[PHP]$time = gmdate('Y-m-d H:i:s a');[/PHP]

what i mean is i want to add 2 days on the current date. how can i do this? your help are appreciate! thanks...

regard Fareast Adam
i have something to calculate the difference between database time and current time ..

see here
[PHP]
$oTime= $res[0]['pass_time']; //this is fetched from DB
$cTime=date('Y-m-d H:i:s');

$diff=strtotime($cTime)-strtotime($oTime);

$hrs=$diff/3600;
return $hrs;
[/php]

hope it helps
cheers !
Sep 23 '07 #2
i've been got the answer. here the answer;

[PHP]gmdate('Y-m-d H:i:s a', mktime(0,0,0,gmdate('m'),gmdate('d')+2,gmdate('Y') ))[/PHP]
Sep 23 '07 #3
pbmods
5,821 Expert 4TB
Heya, Adam.

Given that there are 86400 seconds in a day:

Expand|Select|Wrap|Line Numbers
  1. echo date( 'Y-m-d H:i:s', time() + 86400 * (int) $_GET['offset'] );
  2.  
Sep 23 '07 #4
kovik
1,044 Expert 1GB
... Why make it so difficult, guys?

-_-

[php]date('Y-m-d H:i:s', strtotime('+2 days'));[/php]
Sep 24 '07 #5
pbmods
5,821 Expert 4TB
Heya, Volectricity.

... Why make it so difficult, guys?

-_-

[php]date('Y-m-d H:i:s', strtotime('+2 days'));[/php]
I must be typing something wrong because I can never seem to get that syntax to work right! Maybe it only works if I don't try to precede a date string.

No, that works, too. Maybe it's a version thing. No, that's been available since PHP 4.

Grr. You win this time, Volectricity! :P
Sep 24 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
12
by: Anthony Robinson | last post by:
Is anyone aware of a function (system or user defined) that will calculate business days? For instance: I have a column in as table called DATE. I want to be able to add five business days to that...
2
by: Karen | last post by:
I inserted this statement and it worked great for the customers that have no payment history, but for the customers that have a history and an open invoice, it still used today's date in the mix...
8
by: MLH | last post by:
Anybody's solution would be appreciated. Pls, do not pause to write anything for this. I'm not looking for that kind of a handout. I have an idea about how to do it, but I wanted to see if anyone...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
0
by: dodjem | last post by:
Hi all, I have search far and wide for a solution but have been unsuccessful. I have a database table which contains bookings for resources that can be used in our lab and some bookings can...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
3
by: scan87 | last post by:
Hello everyone, I have a problem with my PHP code. I want to add specific number of days to the current date, so that it will display the correct date after adding the number of days to the...
0
by: geraldjr30 | last post by:
hi, i have the following: <?php echo"test"; //The function returns the no. of business days between two dates and it skips the holidays function...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.