Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-18-2003, 06:43 AM   #1
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
PhP question: Last month

I have to get the last month is simple 1,2,3 format, but I cannot get to it:/

PHP Code:
$lastmonth date("n")-1
This would work, however, NOT if you want to get the rusult 12, like this month the last months'number is 12, not 0.

__________________
seks.ai for sale - ping me
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 06:47 AM   #2
notjoe
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Toronto, Canada
Posts: 5,599
Quote:
Originally posted by Naughty
I have to get the last month is simple 1,2,3 format, but I cannot get to it:/

PHP Code:
$lastmonth date("n")-1
This would work, however, NOT if you want to get the rusult 12, like this month the last months'number is 12, not 0.

$lastmonth = date("m") -1;
if ($lastmonth == 0) {$lastmonth = 12;}


There is a better way to do it using a mktime formula.

http://www.php.net/date

Last edited by notjoe; 01-18-2003 at 06:49 AM..
notjoe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 06:50 AM   #3
Bad B0y
Confirmed User
 
Join Date: Aug 2002
Posts: 160
I have not tested this but I'd expect it to work.

PHP Code:
$lastmonth = (int)date("n") - 1;
// and then notjoe's
if ($lastmonth == 0) {$lastmonth 12;} 

Last edited by Bad B0y; 01-18-2003 at 06:56 AM..
Bad B0y is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 06:53 AM   #4
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
Quote:
Originally posted by notjoe


$lastmonth = date("m") -1;
if ($lastmonth == 0) {$lastmonth = 12;}


There is a better way to do it using a mktime formula.

http://www.php.net/date
I've been there for the past hours, but it returns the seconds format, I have tried many things before coming here to ask. The if-then formula crossed my mind too, but I wanted something else first.

Thanks though.
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 06:56 AM   #5
notjoe
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Toronto, Canada
Posts: 5,599
Quote:
Originally posted by Naughty


I've been there for the past hours, but it returns the seconds format, I have tried many things before coming here to ask. The if-then formula crossed my mind too, but I wanted something else first.

Thanks though.

You could try #php on EFNet (irc), or wait a few hours till i smoke another joint and have a coffee.. once i wake up i'll be able to process php code better ;)
notjoe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 06:58 AM   #6
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
Quote:
Originally posted by Bad B0y
I have not tested this but I'd expect it to work.

PHP Code:
$lastmonth = (int)date("n") - 1
This obviously did not work, as you gave the same solution as we already had.

No Joe's version works well, but it is not what I had in mind

I'll go with that though.
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 07:03 AM   #7
Bad B0y
Confirmed User
 
Join Date: Aug 2002
Posts: 160
Forget my previous post. Here you go:

$lastmonth = date ("n",mktime (0,0,0,date("m")-1,date("d"), date("Y")));

and again I did not test this.
Bad B0y is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 07:11 AM   #8
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
Quote:
Originally posted by Bad B0y
Forget my previous post. Here you go:

$lastmonth = date ("n",mktime (0,0,0,date("m")-1,date("d"), date("Y")));

and again I did not test this.
I already tested that hours ago, didn't work.
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 07:13 AM   #9
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
Quote:
Originally posted by Naughty


I already tested that hours ago, didn't work.
hmm, I must have screwed it up a little when I tried it, it seems to work now
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 12:46 PM   #10
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
In case you're still having issues:

PHP Code:
$lastMonth = (((int)date("m") - 1) > 0) ? (int)date("m") - 12
__________________
 
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 12:49 PM   #11
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,484
Quote:
Originally posted by fletcher
In case you're still having issues:

PHP Code:
$lastMonth = (((int)date("m") - 1) > 0) ? (int)date("m") - 12
I have issues alright .. however, not with this problem anymore
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-18-2003, 12:56 PM   #12
fletcher
Confirmed User
 
Join Date: Jan 2003
Location: Austin, TX
Posts: 698
If you have any questions, hit me up at 225006418 on ICQ and I can most likely give you a hand.
__________________
 
[email protected]
ICQ: 6411138
fletcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.