PHP strtotime time related question

Hello guys,
please help me with this, i have a software done in php,

[php]

‘.date(“F j, Y, h:i A”,strtotime($row[‘created’])).’[/php] this code fetches the created date and time of some post, the out put will be like this February 5, 2013, 1:30 AM , what i am trying here is i would like to add +5 hours while showing out, instead of February 5, 2013, 1:30 AM it should show February 5, 2013, 6:30 AM , this this possible guys?? i tried using this [php]strtotime("+5 hours")[/php] like this [php]’.date(“F j, Y, h:i A”,strtotime($row[‘created’],strtotime("+5 hours"))).’[/php] but its not working, please help guys…

Thank you :slight_smile:

have you looked at this ? http://stackoverflow.com/questions/660501/simplest-way-to-increment-a-date-in-php
[php]strtotime(‘now + 4 hours’[/php]

You were close

[php]date(‘F j, Y, h:i A’, strtotime(’+5 hours’, strtotime($row[‘created’])))[/php]

Another alternative

[php]date(‘F j, Y, h:i A’, (strtotime($created) + (3600 * 5)))[/php]

ohhoww… thankx alot m@tt, thank you, its working, and m@tt how to add minutes?? like what if i want to add +5.30 hours??

cogga, strtotime(‘now + 4 hours’) takes the existing time and adds to it. He wants to take an existing date and add hours to that. Either example that m@tt gave would yield the the same result.

Same thing, either use strtotime

[php]date(‘F j, Y, h:i A’, strtotime(’+5 hours 30 minutes’, strtotime($row[‘created’])))[/php]

Or add the seconds manually

[php]
// 60 * 60 * 6 = 6 hours
// 60 * 30 = 30 minutes

date(‘F j, Y, h:i A’, (strtotime($row[‘created’]) + (60 * 60 * 6) + (60 * 30)))
[/php]

thankx alot m@tt, you really helped me alot, thank you :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service