Closed jurajch closed 6 years ago
Nájsť globálne nastavenie timezone v PHP datetime UTC 0
Timestamps in MySQL generally used to track changes to records, and are often updated every time the record is changed. If you want to store a specific value you should use a datetime field.
If you meant that you want to decide between using a UNIX timestamp or a native MySQL datetime field, go with the native format. You can do calculations within MySQL that way ("SELECT DATE_ADD(my_datetime, INTERVAL 1 DAY)") and it is simple to change the format of the value to a UNIX timestamp ("SELECT UNIX_TIMESTAMP(my_datetime)") when you query the record if you want to operate on it with PHP.
potrebujeme si dat debatu o datetime.
debugoval som ten moj problem s tym, ze po task save sa cas v timepickeroch ulozil mensi o -2hod. prisiel som na zaujimavu vec: ked ukladam cas a datum z datepickeru, api ho prijme spravne. vytvori sa objekt datetime, ktory ma v sebe odoslany cas, datum a timezone. napr 1/1/2017 14:00 GMT (16.00 u nas). potom sa ulozi do entity a posle sa do db, kde sa vsak ulozi ako datetime 1/1/2017 14:00 (bez timezone). potom ked sa vytahuje, tak sa ten cas berie ako 14:00 u nas (nie 14:00 GMT). cize je o 2 hod skorsi.
v com je este problem? vsetky datetime v DB su v timezone servera (cize v nasom). -> zrejme by to malo byt radsej konzistentne v case GMT (=UTC). to sa da spravit jednoduchou konverziou datetime objektu, ale treba to spravit asi vsade, kde sa uklada datum do db.
este jedna vec -> pocas toho ako som to debugoval som spravil hotfix, kde pred ulozenim do db ziskam timestamp datetime objektu, a vytvorim novy datetime objekt z toho timestampu -> vytvori sa v nasej timezone a spravne sa to konvertne. neni to uplne stastne riesenie, ale funguje, a na nase potreby to uplne staci.
cize: netreba robit zatial nic, henten moj hotfix na nase testovacie obdobie staci, ale treba ratat s tym, ze to musime lepsie vymysliet v dalsom milestone. odhadujem to na pol dna debaty / premyslania. hodinu kodenia na api, 3-4- testovanie a kodenie na fronte.