I could go for a massage right about now.
Frigax
@Frigax
Best posts made by Frigax
Latest posts made by Frigax
-
RE: I'm not even sure what to call this
-
Today's date, the long way
Over at a certain website, down at the bottom, they have a "Last Updated" timestamp. It says "Friday, 5th April, 2013." Their site appears to be built in PHP, so that's a quick one-liner, right?
date('l, jS F, Y');
Or maybe not. They decided to build the date string using 126 lines of JavaScript. At least they've anticipated the edge case where it's the "0th" day of the month.
<!-- function ISO8601Local30(date) { // handles years from 0000 to 9999 only var offset30 = date.getTimezoneOffset(); var offsetSign30 = "-"; if (offset30 <= 0) { offsetSign30 = "+"; offset30 = -offset30; } var offsetHours30 = Math.floor(offset30 / 60); var offsetMinutes30 = offset30 - offsetHours30 * 60; return ("000" + date.getFullYear()).slice(-4) + "-" + ("0" + (date.getMonth() + 1)).slice(-2) + "-" + ("0" + date.getDate()).slice(-2) + "T" + ("0" + date.getHours()).slice(-2) + ":" + ("0" + date.getMinutes()).slice(-2) + ":" + ("0" + date.getSeconds()).slice(-2) + "," + ("00" + date.getMilliseconds()).slice(-3) + offsetSign30 + ("0" + offsetHours30).slice(-2) + ":" + ("0" + offsetMinutes30).slice(-2); } var ISO860130 = "0"; function clock30() { var newdate30 = new Date(); if(ISO860130 == "1") { var time30 = ISO8601Local30(newdate30); } else { var day30=""; var month30=""; var myweekday30=""; var year30=""; var mydate30 = new Date(); var dston30 = new Date('March 14, 1999 2:59:59'); var dstoff30 = new Date('November 7, 1999 2:59:59'); dston30.setFullYear(newdate30.getFullYear()); dstoff30.setFullYear(newdate30.getFullYear()); var dst30 = "0"; var myzone30 = newdate30.getTimezoneOffset(); var zone30 = -5; // zone is negative so convert to positive to do calculations if (zone30 <= 0) { zoneb30 = -zone30; } else { zoneb30 = zone30; } if (mydate30 > dston30 && mydate30 < dstoff30 && dst30 == "1") { //date is between dst dates and dst adjust is on. zonea30 = zoneb30 - 1; var houradjust30 = 0; } else { zonea30 = zoneb30; var houradjust30 = -1; }; newtime30=newdate30.getTime(); var newzone30 = (zonea30*60*60*1000); // convert zone back to negative if it was negative originally if (zone30 <= 0) { newzone30 = -newzone30; } newtimea30 = newtime30+(myzone30*60*1000)+newzone30; mydate30.setTime(newtimea30); myday30 = mydate30.getDay(); mymonth30 = mydate30.getMonth(); myweekday30= mydate30.getDate(); myyear30= mydate30.getYear(); year30 = myyear30; if (year30 < 2000) year30 = year30 + 1900; myhours30 = mydate30.getHours(); var mm30 = "am"; if (myhours30 > 11 + houradjust30) mm30 = "pm"; if (myhours30 > 12 + houradjust30) myhours30 -= 12; if (myhours30 == 0) myhours30 = 12; myminutes30 = mydate30.getMinutes(); if (myminutes30 < 10){ mytime30 = "0" + myminutes30; } else { mytime30 = "" + myminutes30; }; myseconds30 = mydate30.getSeconds(); if (myseconds30 < 10) { myseconds30 = "0" + myseconds30; } else { myseconds30 = "" + myseconds30; }; arday30 = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") armonth30 = new Array("January","February","March","April","May","June","July","August","September", "October","November","December") ardate30 = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"); var time30 = (""+arday30[myday30]+","+"�"+ardate30[myweekday30]+"�"+armonth30[mymonth30]+"�"+year30+""); } document.getElementById('ty2udate30').innerHTML = time30; setTimeout("clock30()", 1000) } listen("load", window, clock30); //-->
-
RE: PHP Case WTF
@this_code_sucks said:
Just so you know, you can't do threading and there is no equivlent for Server.Redirect !!!
Do you mean Response.Redirect? If so, you're wanting PHP's header() function.
-
RE: Maybe a nice secluded villa, on the water somewhere - you know, the waves crashing...
What a great place to enjoy the colden years of life.
-
RE: PHP - random garbage collection
Come to think of it, I'm curious what my_rand() is all about, there's probably some serious WTF-ery going on in there. I tend to get nervous when folks decide to "build a better rand()"...
-
RE: PHP - random garbage collection
There's a php.ini setting that controls the probability of the session GC routine firing on any given request. I suspect that whoever wrote this code wanted to reduce the probability, but assumed that many users would be running in environments (shared hosting with PHP in safe mode) where they wouldn't have the appropriate access to do it correctly.
-
RE: Probe into how Google mix-up caused $1 billion run on United
@TooWhiteAndNerdy said:
Don't people read the dates on things anymore?
There was no dateline on the article that sparked all of this... Had there been a date, Google News would not have re-run the story as new.
-
Got my VirtuDyne mug
Thanks! Loved the "WTF" stamp on the box :) Maybe I'll take an action shot...