Conditions are required for exporting data from mongodb
Currently, time is stored in milliseconds. Therefore, you must obtain the number of milliseconds from the shell.
The first thing to say is the + % s parameter of the date command.
I searched the internet, and many people spread messages by mistake. date + % s is millisecond!
Wrong. It's a big mistake, because man said so.
% S seconds since 1970-01-01 00:00:00 UTC
Therefore, the output is from 00:00:00 on January 1, January 1, 1970 to the current second, not in milliseconds.
# Date-d "2014-04-10 00:00:00" + % s
1397059200
So it takes milliseconds to retrieve the x1000.
1397059200000
Then I made another experiment.
Obtain the number of milliseconds in oracle and sqlplus.
Sys @ TESTM> set numwidth 30 // if this parameter is not set, sqlplus uses science to output the result.
Sys @ TESTM> SELECT TO_NUMBER (TO_DATE ('2017-04-10 00:00:00 ', 'yyyy-MM-DD HH24: MI: ss ') -TO_DATE ('1970-01-01 00:00:00 ', 'yyyy-MM-DD HH24: MI: ss') * 24*60*60*1970 as time from dual;
TIME
------------------------------
1397088000000
The preceding SQL statement uses to_date to calculate the number of days from January 1, January 1, 1970 to the current time, multiply by 24 hours to get the hour, * 60*60 to get the second, and then * 1000 to get the millisecond.
However, the number of milliseconds in oracle is different from that in shell!
Let's look back at the explanation of the "date" command % s in man. The last three letters are correct. UTC is the English time!
The time in the UK is eight hours slower than that in Beijing.
1397059200000 + 8x60 X60 x 1000 = 1397088000000
You can also obtain the following information:
# Date-d "2014-04-10 08:00:00" + % s
1397088000x1000
= 1397088000000
######################################## ########
Simple Maintenance
Reprinted please indicate the source
Author: john