Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: String to Unix Timestamp

  1. #1
    Join Date
    Oct 2014

    Question String to Unix Timestamp

    I am using Pentaho data integration ,java script to convert the string variable which contains the date into unix timestamp.
    Following is my string variable

    var str1= getdate.getString() + " " + gettime.getString();

    Here str1 itself generated from the two string in JavaScript.
    My str1 will look like "5-Mar-14 14:13:57".

    Now, please help to turn the str1 into the unix (epoch) timestamp.

    thanks in advance.

    Last edited by yuvam; 12-02-2014 at 03:11 AM.

  2. #2


    You don't need javascript for that, you just can do some calculations in the calculator step starting from a date-field ending in an integer-field with the unix-timestamp
    - convert the date to an integer
    - divide the integer by 1000

    I attached a sample
    Attached Files Attached Files

  3. #3
    Join Date
    Oct 2014


    Hi MUE2000

    Did you tired with string in format as "5-Mar-14 14:13:57" .
    Here I am starting from String field (not Date).

    How to convert this format into unix timestamp.

    Last edited by yuvam; 12-03-2014 at 04:20 AM.

  4. #4


    In your javascript input you mentioned, you startet with a date ?!
    anyway, convert the string to a date, the format should be something like "d-MMM-yy HH:mm:ss" (can be done with calculator step or select values step)
    converting strings to dates is painful if informations are missing, in your string, there is century missing, the day can be one or two digits, ...

  5. #5
    Join Date
    Oct 2014


    Thanks for the reply.

    Actually I got the solution by doing following lines

    temp = Column1.getString() + " " + Column2.getString();
    temp=str2date(temp,"d-MMM-yy H:m:s");

    Unixtime is my required unix (epoch) time.

    Thanks for help and coordinate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.