Dragen Posted June 30, 2007 Share Posted June 30, 2007 I'm getting a wierd result using the date function along with mktime. here's my code: echo date('M', mktime(0,0,0,2)); Looks simple enough.. For some reason though it outputs 'Mar', but march is the third month. If I switch the 2 with 3 it outputs 'Mar'. All the other months come out correctly, just feb comes out as 'Mar' and I can't figure it out... Link to comment https://forums.phpfreaks.com/topic/57847-solved-date-and-mktime-output-mar-instead-of-feb/ Share on other sites More sharing options...
metrostars Posted June 30, 2007 Share Posted June 30, 2007 I think it's something to do with the day, because it is 0, the month technically hasn't started yet, and February is the leap month, im not exactly sure of the problem tho. Put some phony values for year and day and you should be fine. Link to comment https://forums.phpfreaks.com/topic/57847-solved-date-and-mktime-output-mar-instead-of-feb/#findComment-286624 Share on other sites More sharing options...
Dragen Posted June 30, 2007 Author Share Posted June 30, 2007 yeah thanks! I set the day to 1 and it works fine. Thanks Link to comment https://forums.phpfreaks.com/topic/57847-solved-date-and-mktime-output-mar-instead-of-feb/#findComment-286626 Share on other sites More sharing options...
king arthur Posted June 30, 2007 Share Posted June 30, 2007 Because you have omitted the day and year parameters they will default to now. Since it's currently 30th June, and you can't have a 30th February, mktime() converts it into March for you. Link to comment https://forums.phpfreaks.com/topic/57847-solved-date-and-mktime-output-mar-instead-of-feb/#findComment-286628 Share on other sites More sharing options...
Dragen Posted June 30, 2007 Author Share Posted June 30, 2007 ah okay. Thanks Link to comment https://forums.phpfreaks.com/topic/57847-solved-date-and-mktime-output-mar-instead-of-feb/#findComment-286642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.