- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
PHP's Unix time is the number of seconds since Unix Epoch, like everybody else.
Admin
Yes. But given that this is PHP we are talking about readers would be excused for being surprised about that fact.
Admin
This function has the effect of flooring to second. It's a terrible way to do that, but it's not a no-op.
Admin
Except when it shouldn't.
Of course, changing the default timezone can be a WTF in and of itself...
Admin
PHP and WTF have the same character count. Coincidence? Or is it maybe inspiration? Could our ancestors have been inspired to create PHP by access to extraterrestrial knowledge? Could its many insane and idiotic idiosyncrasies be nothing but errors in translation resulting from our inability to understand advanced alien programming paradigms?
See this and more as we reveal the ultimate truth in the next episode of Ancient Programmers.
Admin
LZ79LRU and TROLL do not have he same character count, but they come close.
Admin
time()
returns the time as an integer number of seconds, so it's already floored.Admin
Each parameter of strtime function uses the default time zone unless a time zone is specified in that parameter. Be careful not to use different time zones in each parameter unless that is intended. See date_default_timezone_get() on the various ways to define the default time zone. https://www.php.net/manual/en/function.strtotime.php
Admin
Interesting, I thought it's usually in milliseconds. Oh well, still a giant WTF.
Admin
It's using GMT as the timezone, but the date is in the American month-day-year format. That seems odd.
Admin
I'd like to take the opportunity to share my favourite
atd
"feature":Yes, it understands almost any time spec, including "at teatime", but not the one format it emits.
Admin
What this function is returns a new timestamp that forces the epoch to be 1970-01-01 00:00:00 in the current timezone (whatever that has been configured to be). So if your timezone is at UTC-8 then
yourTime()
(no way is it myTime()) would return a timestamp that is 28800 less than the Unix timestamp.In other words: it takes the Unix timestamp, subtracts the current timezone's offset from UTC, and returns the result.
Addendum 2024-10-17 02:41: Adds, subtracts: depends on which side you're looking at it from.
Admin
"Thank you for sharing this update on the revamped SafetyWing Nomad Insurance claim process! I really appreciate the focus on making it easier and more efficient for travelers. Having reliable and hassle-free insurance is so important for digital nomads, and this is a great step forward. Your post is super helpful!"
"Thank you for sharing this update on the revamped SafetyWing Nomad Insurance claim process! I really appreciate the focus on making it easier and more efficient for travelers. Having reliable and hassle-free insurance is so important for digital nomads, and this is a great step forward. Your post is super helpful!"
Admin
TRWTF is not naming it gmtdate
Admin
The documentation of strtotime leaves me baffled: The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in baseTimestamp, or the current time if baseTimestamp is not supplied.
What is 'the number of seconds since 1 jan 1970 relative to <another time>' meant to mean?
Admin
If it's anything like the C# DateTimeOffset which is described similarly it's basically an offset. So say you have a unix timestamp of 3600 and a date time of now. That would mean now + 1 minute. That sort of thing is really useful when communicating with asinine systems that insist on having their interfaces output all time values in "unix" seconds.
Admin
Indeed, the UNIX epoch time should always be in UTC, as it is the base from which all timezones are calculated from.
If the epoch were to be offset and then fed to any standard tool or function that takes an UNIX epoch value, you would get unexpected results since the expectation is that the value is the "number of seconds since January 1 1970 00:00:00 UTC", emphasis on UTC.