Możliwe obejście byłoby mieć stałą poręczność odpowiadającą sekundom w określonej liczbie lat (najlepiej wielokrotność 4). Możesz dodać tę stałą, przetłumaczyć czas, a następnie odjąć wybraną liczbę lat.
Przykład: wybierz 40 lat.
Ustal Constant:
MySQL [files]> select adddate(from_unixtime(0), interval 40 year);
+---------------------------------------------+
| adddate(from_unixtime(0), interval 40 year) |
+---------------------------------------------+
| 2010-01-01 01:00:00 |
+---------------------------------------------+
1 row in set (0.09 sec)
MySQL [files]> select unix_timestamp(adddate(from_unixtime(0), interval 40 year));
+-------------------------------------------------------------+
| unix_timestamp(adddate(from_unixtime(0), interval 40 year)) |
+-------------------------------------------------------------+
| 1262304000 |
+-------------------------------------------------------------+
1 row in set (0.09 sec)
Teraz możesz każdy unix timestamp x
między 1930 i 20xx i używać go.
select subdate(from_unixtime(x+1262304000), interval 40 year);
Z Twojego przykład -769338000
, masz
MySQL [files]> select subdate(from_unixtime(-769338000+1262304000), interval 40 year);
+-----------------------------------------------------------------+
| subdate(from_unixtime(-769338000+1262304000), interval 40 year) |
+-----------------------------------------------------------------+
| 1945-08-15 17:00:00 |
+-----------------------------------------------------------------+
1 row in set (0.09 sec)
Używanie tego, dziękuję :) –