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

hi friends how to get previous month name according to server date...??
anybody can help me??
thanks in advance

All you need to know on this is at the following link PHP.net Date Function

You could do something to the effect of:
$month_name = date('F', (time()-(60*60*24*30)));

It's a bit hack-ish, but it should work and may spark a better solution.

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?).

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

how about
date('F',strtotime("-1 month"));

Lol, good man - short and to the point, I like it! Big Grin

xwero wins!

strtotime is such a magical function at times Tongue

Theme © iAndrew 2016 - Forum software by © MyBB