1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP modify date string ?

Discussion in 'PHP' started by thesurface, Sep 20, 2012.

  1. #1
    So i have time 2012-09-19 10:42:48

    How can i modify hour 10 to becomes 12 hours ? So +2 hours needed to be replaced :)
     
    thesurface, Sep 20, 2012 IP
  2. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #2
    here is some sample code. the 7200 is 2 hours in seconds.
    
    $date = '2012-09-19 10:42:48';
    echo date ('Y-m-d H:i:s',strtotime($date)+7200);
    PHP:
     
    plussy, Sep 20, 2012 IP
  3. alexkboorman

    alexkboorman Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    as stated above. use strtotime() or if you're making adjustments for timezones there are specific functions for both date offsets and timezone offsets. PHP has particularly good functions for dealing with dates, times and timestamps.
     
    alexkboorman, Sep 23, 2012 IP