Nov 22, 2009

Adding One Day To Date - i'd like to add one day to date

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

Adding One Day To Date - i'd like to add one day to date

adly3000
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.

Comment/Reply (w/o sign-up)

jlhaslip
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.

 

 

 


Comment/Reply (w/o sign-up)

Spectre
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.

Comment/Reply (w/o sign-up)

adly3000
thanks all.Spectre, I think your code is more simple so i used it and it works thatnks again

Comment/Reply (w/o sign-up)

(G)Sreenath
Its really simple. Try this: http://ubshreenath.Spaces.Live.Com/blog/cns!6447FDAF06658642!508.Entry -reply by Sreenath


Comment/Reply (w/o sign-up)

(G)chaviki
check this
Adding One Day To Date

today´s date

[code]$fecha_ini=date("Y-m-d");[/code]

tomorrows date

[code]$fecha_ini = strtotime(date("Y-m-d", strtotime($fecha_ini)) . " +1 day"); [/code]

-reply by chaviki


Comment/Reply (w/o sign-up)

(G)Matt
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

 


Comment/Reply (w/o sign-up)

Echo_of_thunder
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

CODE
<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) 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 -->

Comment/Reply (w/o sign-up)

(G)Dulitha
Adding One Day To Date - i
Adding 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

Comment/Reply (w/o sign-up)

Quatrux
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:

CODE
$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://php.net/strtotime

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : adding, day, date, id, add, day, date

  1. Php Date()?
    timezone is offset (4)
  2. Php Ftp Upload Form
    Adding User Directory to PHP Upload Form - Help (2)
    Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
    folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
    directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
    upload things into the main directory, only sub-directories, is that possible with this coding that
    I have: CODE //uses $_FILES global array //see manual for older PHP version info //This
    function will be used to get the extension from the filename function get_extension($file,$....
  3. Adding String To Integer?
    (1)
    Create a PHP program with the following requirements  Create a program that does the following: 
    creates a variable called “test” (remember the dollar sign)  stores the number 35 to
    test and prints the result  adds 10.0000 to test and prints the result  subtracts 5.123123 from
    test and prints it out  stores the character string “happy to be here” to test and
    prints  adds 10.0000 to the variable test (try to guess what will happen) whats the solution to
    this problem? any help would be appreciated.....
  4. Displaying Date And Time (gmt+8)
    (5)
    how to display date and time (gmt+8)? any help would be appreciated.....
  5. Php Date() Problem [resolved]
    date() seems to loop same ninute. (4)
    My setup is a macbook pro and I have apache+ mysql + php already included I think. the php is
    version 4.4.4 I have been using the date() to store dates into my mysql tables in the past and it
    worked corectly. I dont know what could of happen but now the date() function is returning an
    incorrect time. I made a test script test.php CODE $date_time = date('y-m-d H:m:s');
    echo($date_time); ?> and loaded it up. My laptops system time would be 1.35.33 PM and the date
    and time returned from php would be 07-06-28 13:06:56 I would hit refresh on the brow....
  6. Display The Current Date/time
    With a simple PHP code (4)
    Use this code to display the current date and time. CODE   $date = date('l dS \of F Y
    h:i:s A');   echo "$date"; ?> "l" would display the current day of the week such as
    Sunday. d displays the day of the month... such as 1 and S adds the appropriate suffix(st). /of
    simply displays the word "of". F displays the current month with no abbreviations while Y displays
    the four digit year(2007). "h" displays the current hour with leading zeros if necessary(Ex. 06 for
    6 o'clock). "i" displays the minute of the hour with leading zeros if necessary. ....
  7. Php Codes: Adding Clothing, Ion Laser Guns And Shooting Projectile Cannons
    (3)
    Ok here is a set of codes that is on another forum website. It is really neat becuase you can have
    cursors and other objects on your webpage that can shot projectiles. Also you can add some other
    cool graphics. Go to the link below. php coding ....
  8. Simple Php Calendar And Yahoo! Calendar Connection
    linking each date to Yahoo! calendar (7)
    Original simple PHP calendar source here I was looking for a simple PHP generated calendar. But I
    wanted to place detailed information to show on demand. And installing another database with
    separate management would have been too much of access codes and passwords to remember. And what if
    I want someone else to manage the calendar when I am not able? This is my version of using simple
    PHP calendar script to link to Yahoo! calendar. The twist is that figuring out how Yahoo! calendar
    selection worked. And then depending on which date was clicked it will bring up the a....
  9. Login / Authetication System Using Database
    adding information (4)
    Is there any way to make such database where I can write like name and passwords.. Then make an
    login box, and when somebody trys to acces the login he needs to write the name and password.. Then
    it is verifyed if is there such name and password and if it is then acces the page.. I think there
    is posible something like that with MySQL (db).. but can anybody say me a script or way to make
    something like that? Alredy thanks......
  10. Adding Users To Databases Using Phpmyadmin
    (3)
    I am running my own apache server with PHP and MySQL, with phpMyAdmin on my own computer, to test
    things locally. I know how to create databases and how to create users, but how can I add a user to
    a database?....
  11. Editing Footer.php
    adding a script (2)
    hey can somebody put this script into my footer.php file? because i don't know how. the script
    has to go between the and ok this is the script... CODE clicksor_layer_border_color =
    '#B4D0DC'; clicksor_layer_ad_bg = '#ECF8FF'; clicksor_layer_ad_link_color =
    '#0000CC'; clicksor_layer_ad_text_color = '#000000'; clicksor_text_link_bg =
    ''; clicksor_text_link_color = '#000FFF'; clicksor_enable_pop = false; //-->
    and here is the fotter.php .... CODE /**********************************************....
  12. Phpbb V2.0.16 Has Been Released
    Release Date 06/27/05 (4)
    QUOTE phpBB Group announces the release of phpBB 2.0.16. This release addresses some bugfixes
    and one critical security issue. http://www.phpbb.com/phpBB/viewtopic.php?f=14&t=302011 ....
  13. Sum
    Adding things (11)
    I have this tiny problem, that is I have a whole list of vairables, 25 infact, and I'm trying to
    add them, and store this result in another variable. The problem when I try to call that variable
    the resulting page justs leaves a blank spot, and the IF array that I have won't change, it just
    goes for the first choice. Is this wrong? CODE $var1+$var2+..........$var24+$var25 = $vartotal;
    bearing in mind that there is more in the middle I just didn't feel like typing it!....
  14. Question About The Date() Function In Php
    (4)
    Hi this is the code I've been using. This works perfectly fine with mysql but I'm having
    trouble with getting the exact time. It probably has something to do with time zones and countries.
    Is there something that I need to set to get the time right? I'm from the Philippines and we
    have the same time as Singapore and HongKong. Help please. Tnx. /huh.gif' border='0'
    style='vertical-align:middle' alt='huh.gif' /> CODE $date = date('H:i A, jS F Y');
    ....
  15. Help With Adding Music/video
    help (4)
    Hey, i really need help. How do i add video/ Music to php. If you know please post here nad help
    me. I would really appritiate it. ok thanks.....

    1. Looking for adding, day, date, id, add, day, date

Searching Video's for adding, day, date, id, add, day, date
See Also,
advertisement


Adding One Day To Date - i'd like to add one day to date

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com