Rave Radio: Offline (0/0)
Email: Password:
Page: 1 2 Next »»Rating: Unrated [0]
Programming Challenge
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 4:45am
omgstfudieplzktx
Coolness: 67240
In PHP, using mktime and date() to fetch a timestamp of the current date/time less a month, you will NOT get Sept 31st, but instead get Oct 1st.

In Perl, using Date::Calc::mktime to do the same thing, you get Oct 1st, not Sept 31st.

Perl and PHP share a lot in common though.

So, C/C++ and JAVA programmers, create a timestamp of TODAYS DATE LESS A MONTH and convert the timestamp into a string and see if you get Sept31st or Oct1st.

Note: Only try this October 31st and do not manually feed your timestamp generator the last month, it has to be subtracted from Oct 31st.
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 8:43am
neoform
Coolness: 340390
"less a month,"

... month isn't a variable. minus 30? or minus 31?
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 3:59pm
omgstfudieplzktx
Coolness: 67240
Originally posted by DJNEOFORM...

"less a month,"

... month isn't a variable. minus 30? or minus 31?


Java, C, Perl, PHP, VBS, all have date handling functions.

In other words, you should be able to do $lastmonth = date("M")-1 or an equivalent method in most languages.

I'm just curious to see which one of these languages actually has a sanity check on this operation.
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 4:03pm
neoform
Coolness: 340390
i never touch date.

mktime() is the only way to go.
Good [+1]Toggle ReplyLink» lakester replied on Fri Oct 31, 2003 @ 4:09pm
lakester
Coolness: 60405
10 x=1
20 print x
30 goto 10
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 4:09pm
omgstfudieplzktx
Coolness: 67240
yeah ok

"Topic posted on 1858936739"

But you're not listening.

if you use mktime and date() to get todays time stamp, but on the date() function returning the current month do date("M")-1, you end up with October 1st, not October 31st.

And the same thing happens in Perl as well, but since Perl and PHP
Good [+1]Toggle ReplyLink» lakester replied on Fri Oct 31, 2003 @ 4:11pm
lakester
Coolness: 60405
I love unfinished sentences.
Oh the suspense...
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 4:14pm
neoform
Coolness: 340390
uhh.
if you subtract 1 month from today you *should* get oct 1st.
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 4:19pm
omgstfudieplzktx
Coolness: 67240
no, you shouldn't. This is the thing

no one thought of adding sanity checks for something this simple.

It shouldn't be substracting 31 days, it should be substracting a month.

So the libraries that handle this should do a check to see if the month you're substracting to has 31, 30, 29 or 28 days.

Imagine you were March 31st on a leap year and substract one month from it, you'd end up at March 2nd or 3rd.

Its a stupid way of handling things, causing extra code just to handle what should be simple date calculations.
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 4:22pm
neoform
Coolness: 340390
..

prehaps. but thats just the developers faults for making the language do that.

its up to you to make your app fix this problem by not using the -1 month.
Good [+1]Toggle ReplyLink» Zz.ee.vV replied on Fri Oct 31, 2003 @ 4:32pm
zz.ee.vv
Coolness: 194750
i broke out the dusty borland C++ and it gave me september 30th.
Good [+1]Toggle ReplyLink» lakester replied on Fri Oct 31, 2003 @ 4:34pm
lakester
Coolness: 60405
Originally posted by AM I DEATH?...

In PHP, using mktime and date() to fetch a timestamp of the current date/time less a month, you will NOT get Sept 31st, but instead get Oct 1st.


September 31st is like Santa Claus.

It doesn't exist.
Good [+1]Toggle ReplyLink» Screwhead replied on Fri Oct 31, 2003 @ 4:35pm
screwhead
Coolness: 686315
*waits and watches as another episode of You Should Follow Scalability Standards And Need To Learn To Code Because I 0wn Joo Ph34r My M4d 5ki11z0r unfolds*
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 4:38pm
neoform
Coolness: 340390
*sneaks up behind fred and pulls a paul*
Good [+1]Toggle ReplyLink» Screwhead replied on Fri Oct 31, 2003 @ 4:38pm
screwhead
Coolness: 686315
*flexes ass muscles and rips ian's dick off*
Good [+1]Toggle ReplyLink» neoform replied on Fri Oct 31, 2003 @ 4:41pm
neoform
Coolness: 340390
ahh! even you ass has fangs!!!
Good [+1]Toggle ReplyLink» Screwhead replied on Fri Oct 31, 2003 @ 4:43pm
screwhead
Coolness: 686315
Yeah, it's halloween, duhh! My ass is a vampire and my dick is possesed.

It's really cool. My nuts are singing.
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 4:54pm
omgstfudieplzktx
Coolness: 67240
Originally posted by LAKESTER...

Originally posted by Am I Death?...

In PHP, using mktime and date() to fetch a timestamp of the current date/time less a month, you will NOT get Sept 31st, but instead get Oct 1st.


September 31st is like Santa Claus.

It doesn't exist.


And this is my point. September 31st doesn't exist. You SHOULD be getting September 30th, but someone somewhere was lazy and decided to throw the extra 10 minutes of work necessary to achieve this goal on us.
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX replied on Fri Oct 31, 2003 @ 4:56pm
omgstfudieplzktx
Coolness: 67240
Originally posted by SPOOKY...

*waits and watches as another episode of You Should Follow Scalability Standards And Need To Learn To Code Because I 0wn Joo Ph34r My M4d 5ki11z0r unfolds*


this has nothing to do with standards, this has to do with other people's faults at not adding mundane checks and making the coder do dirty work that should not other wise be doing.
Good [+1]Toggle ReplyLink» lakester replied on Fri Oct 31, 2003 @ 4:59pm
lakester
Coolness: 60405
ever hear of the Y2K bug?
Programming Challenge
Page: 1 2 Next »»
Post A Reply
You must be logged in to post a reply.