how to display last month in full textual format
Moderator: General Moderators
-
konstandinos
- Forum Commoner
- Posts: 68
- Joined: Wed Oct 04, 2006 4:20 am
how to display last month in full textual format
hello folk
i can get last month numerically by simply going date('m')-1 (which would currently return 11)
but i want the format date('F') -> ie: November
obviously date('F')-1 doesn't work.
any ideas?
thanks
i can get last month numerically by simply going date('m')-1 (which would currently return 11)
but i want the format date('F') -> ie: November
obviously date('F')-1 doesn't work.
any ideas?
thanks
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
echo date('F', strtotime('-1 month'));-
konstandinos
- Forum Commoner
- Posts: 68
- Joined: Wed Oct 04, 2006 4:20 am
it needs to be automated. i dont want to have to hard-code the last month in an echo statement. since in one month's time that will change (pardon me being to patronizing).
so basically i want date('m')-1 functionality, but instead of displaying 11, i want to display november (and when we're in february i want it to say january etc).
make sense?
so basically i want date('m')-1 functionality, but instead of displaying 11, i want to display november (and when we're in february i want it to say january etc).
make sense?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
My bad, I took what you said in the completely wrong sense.. one of those days you know? Though you meant you wanted the 2nd last month of the year.. for whatever reason.konstandinos wrote:it needs to be automated. i dont want to have to hard-code the last month in an echo statement. since in one month's time that will change (pardon me being to patronizing).
so basically i want date('m')-1 functionality, but instead of displaying 11, i want to display november (and when we're in february i want it to say january etc).
make sense?
Last edited by John Cartwright on Mon Dec 18, 2006 4:16 pm, edited 1 time in total.
-
konstandinos
- Forum Commoner
- Posts: 68
- Joined: Wed Oct 04, 2006 4:20 am
-
konstandinos
- Forum Commoner
- Posts: 68
- Joined: Wed Oct 04, 2006 4:20 am
ok another problem with date...
im basically pullin up historical dates, which have been stored in my dbase as YYYY-mm-dd, and i'm echo'ing them as Month_name, YYYY.
ie: stored as 2006-12-18, and echo'ed as 'December, 2006'.
so now say that one of my dates is 2006-01-21.
how do i use the date() function to print 'January, 2006'?
im basically pullin up historical dates, which have been stored in my dbase as YYYY-mm-dd, and i'm echo'ing them as Month_name, YYYY.
ie: stored as 2006-12-18, and echo'ed as 'December, 2006'.
so now say that one of my dates is 2006-01-21.
how do i use the date() function to print 'January, 2006'?
Again strtotime is your friend to get the unix timestamp you can use with date().
see http://de2.php.net/strtotime and http://de2.php.net/date
see http://de2.php.net/strtotime and http://de2.php.net/date