Description
But with next things: The reason of above is IMPORTANT difference between relative and absolute date. Relative date comes from your CPU clock. You write "today" or "yesterday" and you'll get for me (now): Ok, lets remember your server
(and your postgres configured with UTC). You apply
You ALWAYS get unexpected difference in (for me) 2 hours. So the time will be: But wait, now you should do that in your brain on every math operation, and try to remember it. How to get same date as you see in your mac/windows/ubuntu tray, huh, developer? Tada (it isnt "correct", its "usable", btw humans always incorrect):
How many hours newbie should spent to research that ?? The point is difference between RELATIVE and ABSOLUTE dates. If you pass timezone as 2nd parameter with relative date - it will be applied like "create date, then - change timezone", instead of "create MY date in described timezone", do you get that? BUT, we want to apologize - "today midnight" isnt a RELATIVE date. Actually not fully relative. It creates the date with 00:00:00 timestamp. And it will surprise you only if date been created inside UTC difference (for me) 2 hours from UTC. There will be previous day, but server awaits next one. How about create DIFFERENT classes for Relative date and Absolute date? Postgres solves that by presenting two different types \DateTime + \DateTimeWithTimezone. Problem of that - you cant just add timezone for non-timezone date, so postgres wont solve that Or fix the behavior - "today, UTC" means "GET MY TIME IN UTC, I KNOW ITS A MISTAKE, BUT IT WILL HELP ME" :DD And the next point. When we serialize date into some storage, we need DATE_ATOM or maybe sql date format. So creating date with
Lets rewrite:
To create date in PHP safely you need to always write that construct. In each class you need dates. And am not speaking about
Lets fix at least relative date stuff. Just to reduce syntax. Other stuff we could speak later. Thanks for your time, folks. Be safe. [ Гриша, ты уже всех достал своим английским, уходи ] |