Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "strtotime"
That moment that you come across a domain name which you thought would have definitely been taken already.
Came across strtoti.me. (php function for converting date/time strings into unix epoch's). Quickly wrote an api for it and put it online because fuck it, why not!
Feel free to use it as much as you want, I can't guarantee its availability unless it would become really popular but I can't imagine that.
API example: https://strtoti.me//... 20 20:15
API example (url encoded): https://strtoti.me//...
API documentation (not that good yet, might improve it..): https://strtoti.me
Well, let's see how this goes. Feedback appreciated but I currently have a shitload of projects to it doesn't have the highest priority right now!13
I had a four month (paid!) internship this summer, being handed compete control over a custom built, naturally-grown e-commerce site (oh the stories). When I was working on rewriting the admin panel page that showed a list of orders placed, I hit PHP's date parsing... "behavior".
Despite passing a formatting string to `strtotime()` so the date from the database (MySQL VARCHAR field containing a value from `time()`, which was generated when the order was placed and doubled as the order number) would be formatted correctly, I discovered PHP basically ignores it and uses the date delimiter to determine if the date should be formatted in American or European format.
Basically, if the date uses dots or dashes for the delimiter, it is displayed in European format, DD-MM-YYYY. If the delimiter is a forward slash, the output is American, MM/DD/YYYY.
Although this is strictly an American website, this might have been fine if I did not want the date to be formatted as MM-DD-YYYY. To resolve this, I wrote the following function, including the comment, and put it in my common utils module for use where I needed it.
In almost 4 years of programming, this is probably the one thing I am most ashamed of writing.12
FUCK YOU PHP, WHY THE FUCK DO YOU GIVE ME DECEMBER 1ST WHEN I DO
strtotime('-1 month', '12/31/2015)
USING DateTime PRODUCES THE SAME FUCKING RESULT. ARE YOU FUCKING RETARDED OR WHAT?
YEAH I KNOW NOVEMBER DOESN'T HAVE 31ST BUT YOU COULD AT LEAST RETURN 30TH OR EVEN RAISE A WARNING, YOU FUCKING PIECE OF SHIT.10
define("NOW", date("Y-m-d H:i:s", time());
/* ..... more code ..... */
$nowUnix = strtotime(NOW);1
Second rant today....
Can the class explain the following query and why I started wishing the author might suffer pain even after death?
$date1 = strtotime($_REQUEST['year1'].'-'.$_REQUEST['month1'].'-01');
$date2 = strtotime($_REQUEST['year2'].'-'.$_REQUEST['month2'].'-31');
MONTH(FROM_UNIXTIME($date1)) >= MONTH(FROM_UNIXTIME(timestampColum))
MONTH(FROM_UNIXTIME($date2)) <= MONTH(FROM_UNIXTIME(timestampColum))
But... The drugs the author must have taken to write this must be frigging awesome.10