rantsh Posted January 29, 2007 Share Posted January 29, 2007 I'm trying to get the hour of 15 minutes ago with strtotime and I'm using the following code[code]$this->timeStr = "2007-01-29 10:11:54";$datenew = date("Y-m-d H:i:s",strtotime("-15 minute",$this->timeStr)); [/code]and can't seem to make it work, I've tried with [b]minute [/b](singular) and [b]minutes [/b]and still no good... the output of this operation is [b]1969-12-31 20:18:27[/b] I have no clue of what's going on.....!!!!does anyone know what can be wrong??? Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/ Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 try:$time = strtotime("now") - 900;but this will be in the strtotime form, you will need to convert it...Ted Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171811 Share on other sites More sharing options...
rantsh Posted January 29, 2007 Author Share Posted January 29, 2007 Thanks Ted, That worked, but, is there a shorter way to deal with this code? (just wondering)Thx Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171815 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 i think this is aligant enough, but i remember there is some other way to do it, forgot ;DTed Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171816 Share on other sites More sharing options...
HuggieBear Posted January 29, 2007 Share Posted January 29, 2007 It should be as simple as[code=php:0]$timestamp = strtotime("-15 min");$time_fifteen_mins_ago = date("Y-m-d H:i:s", $timestamp);[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171827 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 I see, ahh. i remember seen it somewhere, so this:$timestamp = strtotime("-1 year");$timestamp = strtotime("-1 month");should work too?Ted Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171850 Share on other sites More sharing options...
HuggieBear Posted January 29, 2007 Share Posted January 29, 2007 That's correct.Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171858 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 cool 8) Quote Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171860 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.