Problem with epoch time

Hi All,

I have a weird problem. I have a session log which is in .bin format. I am converting the .bin file to xml format using Informatica(it is an ETL tool) and unix functionality called "convertLogFiles" . All this is working fine. The session log has a date column. After converting the log to xml format, the date value is getting converted to unix time - epoch time. The strange part is, after the conversion the epoch time is 13 digits. Below are some of the date values from the log:

Actual date value:

2014-03-13 20:30:11

After conversion, Epoch time value:

1394713811052

Now i need to load this epoch time value to a Oracle table. So i am converting it using the date command in unix. This epoch time value is not proper ! What i mean is, if i convert the epoch value to date format, it is giving some other value!

date -d @1394713811052
 
Output i am getting 
 
Sun Sep 21 07:04:12 SGT 46166

Please help in resolving this issue. Or is there any way where i can avoid converting the time to epcoh value.

You might be trying something wrong see result here

[akshay@aix tmp]$ date -d '2014-03-13 20:30:11'
Thu Mar 13 20:30:11 IST 2014

[akshay@aix tmp]$ date -d '2014-03-13 20:30:11' +%s
1394722811

[akshay@aix tmp]$ date -d @$(date -d '2014-03-13 20:30:11' +%s)
Thu Mar 13 20:30:11 IST 2014

[akshay@aix tmp]$ date -d @1394722811
Thu Mar 13 20:30:11 IST 2014

---------- Post updated at 04:09 PM ---------- Previous update was at 04:06 PM ----------

2014-03-13 20:30:11 != 1394713811052
$ date --v
date (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.

It seems to me there are 3 digits too many, probably it is Epoch in milliseconds:

$ date -d @1394713811.052
Thu Mar 13 13:30:11 CET 2014
dd=1394713811052
date -d "@$(echo "$dd/1000"|bc)" 
1 Like

Hi Scrutinizer,

Yes you are correct. The date was in milliseconds. And your solution worked perfectly ! Thank you :slight_smile: