Welcome Guest, Not a member yet? Register   Sign In
Previous month name
#4

[eluser]Lone[/eluser]
Ok, you got me thinking on this and its not that easy to achieve in one line really because if month is January then current month less one is 0 not 12.

ucantblamem's solution is a good quick fix but the issue is obvious that not all months have 30 days...

Heres the best solution I could come up with - any suggestions welcome (such as something cleaner then mktime?).

Code:
if( ($monthPrevious = 1-1) == 0) {
    $monthPrevious = 12;
}

$monthPreviousName =  date('F',mktime(0,0,0,$monthPrevious,1,2000));

A previous date function in the date helper could come handy looking at this Smile


Messages In This Thread
Previous month name - by El Forum - 01-31-2008, 01:05 AM
Previous month name - by El Forum - 01-31-2008, 01:15 AM
Previous month name - by El Forum - 01-31-2008, 01:16 AM
Previous month name - by El Forum - 01-31-2008, 01:27 AM
Previous month name - by El Forum - 01-31-2008, 01:29 AM
Previous month name - by El Forum - 01-31-2008, 01:31 AM
Previous month name - by El Forum - 01-31-2008, 01:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB