SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-19-2004, 11:10 AM
fourthring fourthring is offline
SEO
 
Join Date: Oct 2004
Posts: 155 fourthring is on a distinguished road
php to get previous month's name?

Hi I know there is probably a thousand ways to do this but is there a quick way using the date() function to find the last month's full name?

$today = getdate();
$month = $today['month'];

or

$month= date('F');

This would give me 'November' for this month but how do I get the previous month's name?

I know I coud just make an array with all the names of all the months and subtract one but I dont' want to have to deal with the problem when a new year rolls around. Right now I have a hack and it just checks to see if the month numeral is equal to 0 (january) then subtract from 12 to get 11 (december).but I was wondering if there is a cleaner way that this?

Thanks

Last edited by fourthring : 11-19-2004 at 11:19 AM.
Reply With Quote
  #2  
Old 11-25-2004, 02:09 AM
l3vi l3vi is offline
SEO Almost
 
Join Date: Nov 2004
Posts: 119 l3vi is on a distinguished road
Yep,

$month = date("F", mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));

Enjoy!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 09:39 AM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.