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??? 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 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 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 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 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 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 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) Link to comment https://forums.phpfreaks.com/topic/36181-problem-with-strtotime/#findComment-171860 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.