zc1 Posted January 18, 2008 Share Posted January 18, 2008 Hi, I would like to if possible to convert the mktime to strtotime, I have looked at the strtotime on php.net and it went right over my head, so I was wonder if someone could help me to convert the below from mktime into strtotime if it possible The below is the from the script I am trying to get to work $showMonth = date("F Y", mktime(0,0,0,$Month,1,$Year)); $numDays = date("t",mktime(0,0,0,$Month,1,$Year)); $startDay = date("w",mktime(0,0,0,$Month,1,$Year)); $prevMonth = date("m", mktime(0,0,0,($Month - 1), 01, $Year)); $prevYear = date("Y", mktime(0,0,0,($Month - 1), 01, $Year)); $nextMonth = date("m", mktime(0,0,0,($Month + 1), 01, $Year)); $nextYear = date("Y", mktime(0,0,0,($Month + 1), 01, $Year)); $todaysDay = date("w", mktime(0,0,0,$Month, $q, $Year)); if ( date("m", mktime(0,0,0,$Month, $q, $Year)) == date("m", mktime(0,0,0,$Month, ($q - 7), $Year)) ) { Regards, Garry Link to comment https://forums.phpfreaks.com/topic/86660-solved-mktime-to-strtotime-convert-if-possible/ Share on other sites More sharing options...
zc1 Posted January 18, 2008 Author Share Posted January 18, 2008 I got the mktime working Link to comment https://forums.phpfreaks.com/topic/86660-solved-mktime-to-strtotime-convert-if-possible/#findComment-442882 Share on other sites More sharing options...
cooldude832 Posted January 18, 2008 Share Posted January 18, 2008 strtotime by design ins't meant to be used on none user input except for when you are doing the "+1 Day", "-1 Week" etc varients. Its primary purpose is to take a formated date (like mm/dd/yyyy or mm-dd-yyyy or yyyy-mm-dd) and spit out a unix time stamp with association to what it knows about the input. in your case you are setting times to the begining of a month for the most part the $preYear,$nextmonth can be handled by saying $prevYear = date("Y", strtotime("-1 year",$Year)); however from a amount of processing time that would take more as your taking a valid time item (year) and treating it like a raw string just to convolute it to put it back into a time, it would also probably return jan 1 12:00 am on the previous year not what you want exactly (although you just want the Y part of it) as you can see in this case its not much help in the long run actually slower Link to comment https://forums.phpfreaks.com/topic/86660-solved-mktime-to-strtotime-convert-if-possible/#findComment-442885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.