I send data present in my database to this third party system. It only imports dates correctly when I use PHP's strtotime * 1000:
$data = strtotime('2015-12-08 15:12:16') * 1000; // output: 1449594736000
I want to generate all data only with my PostgreSQL database, without using PHP. So I tried it:
SELECT EXTRACT(EPOCH FROM '2015-12-08 15:12:16'::DATE) * 1000; -- output: 1449532800000
By using this PostgreSQL way, the third party system imports dates wrong.
How can I generate the same output generated by PHP with my PostgreSQL database?
What could be causing this difference?
Looks like you need convert data to timestamp in UTC +2
# SELECT EXTRACT(EPOCH FROM '2015-12-08 15:12:16'::timestamp without time zone + interval '2 hour')*1000;
?column?
---------------
1449594736000
(1 row)