Jump to content
xisto Community
Sign in to follow this  
adly3000

Adding One Day To Date id like to add one day to date

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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://forums.xisto.com/topic/30336-restricting-page-access-using-php-need-help/
Also, try this code found at the php.net site:

$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:
   $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.

Share this post


Link to post
Share on other sites

Try this:

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.

Share this post


Link to post
Share on other sites
check thisAdding One Day To Date

today?s date

$fecha_ini=date("Y-m-d");

tomorrows date

$fecha_ini = strtotime(date("Y-m-d", strtotime($fecha_ini)) . " +1 day");
-reply by chaviki

Share this post


Link to post
Share on other sites
Spoke too soon.Adding One Day To Date

Actually, it seems I didn't look closely enough at chaviki's suggestion, which will probably take daylight saving into account.  I didn't know you could do that with strtotime(), thanks.

-reply by Matt

 

Share this post


Link to post
Share on other sites

This is the one I use on my site. it welcomes you with by good morning or evening and gives the date and day
GL

<script type="text/javascript">try {var pageTracker = _gat._getTracker("UA-7324896-1");pageTracker._trackPageview();} catch(err) {}</script><!-- /mod_php version 1.0.0.Beta2 (c) http://www.fijiwebdesign.com/ --><!-- script to display greeting --><script language="JavaScript"><!-- var Greeting = "Hello. ";var Today = new Date();var CurrentHour = Today.getHours();if (CurrentHour < 12) { Greeting = "Good Morning, today is  "; }if (CurrentHour >= 12 && CurrentHour < 17) { Greeting = "Good Afternoon, today is "; } if (CurrentHour >= 17) { Greeting = "Good Evening, today is "; } document.write(Greeting); //--></script><noscript>Hello and Welcome to ECHO OF THUNDER WEATHER </noscript><!-- end of greeting script --><!-- script to display full date --><script language="JavaScript"> var Today = new Date();var Days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");var Months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");var Year = Today.getYear();if (Year < 1000) { Year += 1900; }var Day = Today.getDate();var DateEnding = "";if (Day == 1 || Day == 21 || Day == 31) { DateEnding = "st"; }else if (Day == 2 || Day == 22) { DateEnding = "nd"; }else if (Day == 3 || Day == 23) { DateEnding = "rd"; }document.write( Days[Today.getDay()] + " " + DateEnding + " " + Months[Today.getMonth()] + " " + Day + " , " + Year );</script><!-- end of date script -->

Share this post


Link to post
Share on other sites
Adding One Day To Date - iAdding One Day To Date

I think, following code works perfectly.

<?php

echo $lasthour = mktime(0, 0, 0, date("m"), date("d")+1, date("Y"));

?>

-reply by Dulitha

Share this post


Link to post
Share on other sites

As I know mktime(); is a great function, but if you can, try to not use it, the easiest and most understandable way to add one day to current time in my opinion is doing it like this:

$tomorrow = date( "Y-m-d H:i:s", strtotime("+1 day") );echo $tomorrow;

You can read more about this great function on the manual: http://de2.php.net/strtotime

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.