Created 07-21-2016 01:18 PM
Hi experts, I've the following field: 1388481000000 as the number of milliseconds elapsed from the Unix Epoch (1970-01-01 UTC) How can I convert to Unix TimeStamp? I'm trying to use ToUnixTime(1388481000000,'dd/MM/yyyyHH:mm:ss','GMT') but it gives me error... How can I convert into Unix Timestamp? Many thanks!
Created on 07-21-2016 11:28 PM - edited 08-19-2019 01:18 AM
Hi @Johnny Fugers,
Input file data as: dataset.csv
This gives answer in CET
563355,1388481000000
563355,1388481000000
563355,1388481000000
563356,1388481000000
a = load '/tmp/dataset.csv' using PigStorage(',') as (id:chararray, at:chararray);
b = foreach a generate id, ToString( ToDate( (long)at), 'yyyy-MM-dd hh:ss:mm' );
c = group b by id;
dump c;
This is how it works in GMT:
a = load '/tmp/dataset.csv' using PigStorage(',') as (id:chararray, at:chararray);
b = foreach a generate id, ToDate(ToString(ToDate((long) at), 'yyyy-MM-dd hh:ss:mm'), 'yyyy-MM-dd hh:ss:mm', 'GMT');
c = group b by id;
dump c;
Hope that helps,
Thanks,
Sujitha
Created on 07-21-2016 11:28 PM - edited 08-19-2019 01:18 AM
Hi @Johnny Fugers,
Input file data as: dataset.csv
This gives answer in CET
563355,1388481000000
563355,1388481000000
563355,1388481000000
563356,1388481000000
a = load '/tmp/dataset.csv' using PigStorage(',') as (id:chararray, at:chararray);
b = foreach a generate id, ToString( ToDate( (long)at), 'yyyy-MM-dd hh:ss:mm' );
c = group b by id;
dump c;
This is how it works in GMT:
a = load '/tmp/dataset.csv' using PigStorage(',') as (id:chararray, at:chararray);
b = foreach a generate id, ToDate(ToString(ToDate((long) at), 'yyyy-MM-dd hh:ss:mm'), 'yyyy-MM-dd hh:ss:mm', 'GMT');
c = group b by id;
dump c;
Hope that helps,
Thanks,
Sujitha