Results 1 to 6 of 6

Thread: Looking for an addition

  1. #1
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default Looking for an addition

    How do I add two hours to this code?
    PHP Code:
    $date date("Y-m-d");
    $time date("g+2:i a"); 
    I tired this but it actually displays the time with a "+2" in the center of it.
    PHP Code:
    $date date("Y-m-d");
    $time date("g+2:i a")+2
    Last edited by Dirt_Diver; 01-09-2009 at 02:56 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I would just do something like:
    PHP Code:
    <?php
    $date 
    date("Y-m-d "); 
    $time date("g:i a"strtotime("+2 hours"));
    echo 
    $date.$time;
    ?>
    Last edited by Nile; 01-09-2009 at 02:52 AM.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    Dirt_Diver (01-09-2009)

  4. #3
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    I also tired this but got a fatal error

    PHP Code:
    date_default_timezone_set('America/New_York'); 

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I've made an edit to my post, look above.
    When using date_default_timezone_set, you also have to include a _get below it.
    [From what I understand]
    Jeremy | jfein.net

  6. The Following User Says Thank You to Nile For This Useful Post:

    Dirt_Diver (01-09-2009)

  7. #5
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    Ahhh yes thanks again Buddy.

  8. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Anytime, you could also use the mktime function if you wanted.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •