Convert json date (millisecond value) to a date string



  • Good Day to everyone.
    I have a little problem. I need convert the time i parsed to a date string format beacuse its in milliseconds.

    There is the format : 1036022400000-0500
    There is the value to a data string that i need: Wed Oct 30 2002 19:00:00 GMT-0500

    How to do this in openbullet? I tried FUNCTION UnixtimetoISO8601 but its one day upper.
    UnixTimeToISO8601: 2002-10-31T00:00:00.000Z

    I Think this its beacuse the timezone, how to do this?
    Thanks for the help


  • Admin

    That's because timezones arent supported by OB's time conversion functions



  • Do you not have a solution in mind to convert it? Also, thanks for the quick help. @Ruri


  • Admin

    Well, there is a solution yes. Parse the first part 1036022400 and 2nd part -05 and then use compute block to add <unix> + <timezone> * 3600 aka the seconds in an hour * n of hrs and then use isi8601 on the result



  • I tried but im not getting the result i was expecting

    <--- Executing Block PARSE --->
    Parsed variable | Name: DATE | Value: 1036022400000

    <--- Executing Block FUNCTION --->
    Executed function Compute on input 1036022400000+0500*3600 with outcome 1036024200000
    Parsed variable | Name: UNIX | Value: 1036024200000

    <--- Executing Block FUNCTION --->
    Executed function UnixTimeToISO8601 on input 1036024200000 with outcome 2002-10-31T00:30:00.000Z
    Parsed variable | Name: | Value: 2002-10-31T00:30:00.000Z

    What im doing bro?

    Also Tried :

    <--- Executing Block PARSE --->
    Parsed variable | Name: DATE | Value: 1036022400000

    <--- Executing Block FUNCTION --->
    Executed function Compute on input 1036022400000+05*3600 with outcome 1036022418000
    Parsed variable | Name: UNIX | Value: 1036022418000

    <--- Executing Block FUNCTION --->
    Executed function UnixTimeToISO8601 on input 1036022418000 with outcome 2002-10-31T00:00:18.000Z
    Parsed variable | Name: | Value: 2002-10-31T00:00:18.000Z


  • Admin

    That's cause you parsed milliseconds, not seconds. If you parse ms you have to multiply by 3600 * 1000



  • FUNCTION Compute "1036022400+-05*3600" -> VAR "Calculate" 
    
    FUNCTION UnixTimeToISO8601 "<Calculate>" -> CAP "Date" 
    
    

Log in to reply