Discussions

Expand all | Collapse all

Setting Time Stamp with API_EditRecord Using Epoch Milliseconds

  • 1.  Setting Time Stamp with API_EditRecord Using Epoch Milliseconds

    Posted 28 days ago
    Edited by Ad Planner System 28 days ago
    I can successfully set a time stamp value using API_EditRecord by supplying a number of milliseconds since 01-01-1970.  This is a 13-digit integer, generated from a 10-digit epoch time (seconds) provided by my operating system, multiplied by 1000. My users are in the United States Central Time Zone, and my app is configured to display times as US Central Time. US Central Standard Time is six hours "behind" Coordinated Universal Time (UTC).

    When I update the time stamp using a US Central Time epoch milliseconds value, my app displays a time six hours in the future.  For example if I set the time to be 12-30-2020 3:15:00 PM, it's displayed in the app as 12-30-2020 9:15:00 PM.  If I subtract six hours from the time stamp I actually want to use, the time is displayed appropriately in my app.

    Can anyone confirm that this is the expected behavior, and that my time stamp value requires a time zone offset (-6 hours, or -5 for Daylight Savings Time) in order to display correctly in my app?   Thanks for reading ...

    ------------------------------
    Ad Planner System Admin
    Technical Solutions Specialist
    RR Donnelley
    ------------------------------


  • 2.  RE: Setting Time Stamp with API_EditRecord Using Epoch Milliseconds

    Posted 28 days ago
    I believe that's the expected behavior.  The milliseconds value doesn't include any time zone offset information so it makes sense to treat all values as UTC.  The API will accept a string format like MM-dd-yyyy H:mm to update date/time fields which can be a bit easier to generate in UTC especially in JavaScript where you have UTC specific methods on Date objects.

    let d = new Date();
    let formattedDateString = `${d.getUTCMonth()+1}-${d.getUTCDate()}-${d.getUTCFullYear()} ${d.getUTCHours()}:${d.getUTCMinutes()}`​


    ------------------------------
    Nathan Hawe
    ------------------------------



  • 3.  RE: Setting Time Stamp with API_EditRecord Using Epoch Milliseconds

    Posted 28 days ago
    Thanks, Nathan, that is very helpful.   --Jeffrey

    ------------------------------
    Ad Planner System
    Technical Solutions Specialist
    RR Donnelley
    ------------------------------