- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Convert millseconds into Unix TimeStamp
- Labels:
-
Apache Pig
Created ‎07-21-2016 01:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
