Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Adding One Day To Date, i'd like to add one day to date
adly3000
post Feb 17 2006, 06:00 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 58
Joined: 31-January 06
Member No.: 17,937



I would like to add one day to date.Doesn't any one have a simple code that I can have.
or mabe a link.

date("Y-m-d H:i:s") + (1800 * 24);//this doesnt work ;/ but i need to have 24 hours after date for a check.

Thanks for taking the time i hope some one can help me out. Dont warry about it if you dont have some thing already made.
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 17 2006, 06:54 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,954
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



I think the clock function is based on seconds, so 1 day = 24 hrs * 60 min * 60 secs might work better?
(24*60*60)=86,400 seconds in a day.
http://www.trap17.com/forums/index.php?s=&...ndpost&p=206915
Also, try this code found at the php.net site:
CODE

$this_day=date("Y-m-d H:i:s");
$tomorrow=$this_day + 86400;

This should work if the results from the date function can be manipulated in an arithmetic manner. That I do not know, but I can't see why not. The function probably returns the number of seconds since the Unix epoch of midnight Jan 1, 1970 (I think). Otherwise, this might be required:
CODE

   $jump=1;
   $evalday = mktime(strftime ("%d/%m/%Y", strtotime("+$jump days")));


Have a look at the php.net site for more info. Search for the date function at the top of the page.
Go to the top of the page
 
+Quote Post
Spectre
post Feb 18 2006, 05:00 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



Try this:

CODE
date("Y-m-d H:i:s", time()+((60*60)*24));


The date() function calculates the current date based on a UNIX timestamp, which is the number of seconds passed in the UNIX epoch (from 00:00:00 01/01/1970). So to add 24 hours, you simply need to add the number of seconds that exist in 24 hours to the current timestamp - which is (60^2)*24 or 86400 seconds - and pass that to the date() function. Hope that makes sense.
Go to the top of the page
 
+Quote Post
adly3000
post Feb 19 2006, 10:43 PM
Post #4


Member [Level 1]
****

Group: Members
Posts: 58
Joined: 31-January 06
Member No.: 17,937



thanks all.Spectre, I think your code is more simple so i used it and it works thatnks again
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Sum(11)
  2. Phpbb V2.0.16 Has Been Released(4)
  3. Editing Footer.php(2)
  4. Adding Users To Databases Using Phpmyadmin(2)
  5. Login / Authetication System Using Database(4)
  6. Simple Php Calendar And Yahoo! Calendar Connection(7)
  7. Php Codes: Adding Clothing, Ion Laser Guns And Shooting Projectile Cannons(3)
  8. Display The Current Date/time(3)
  9. Php Date() Problem [resolved](4)
  10. Displaying Date And Time (gmt+8)(5)
  11. Adding String To Integer?(1)
  12. Php Ftp Upload Form(0)
  13. Php Date()?(4)


 



- Lo-Fi Version Time is now: 21st August 2008 - 01:37 AM