Announcement

Collapse
No announcement yet.

Date in Unix

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date in Unix

    Hello, in an API request I receive the date in Unix format. How can I convert, for example, '1719240582' to give us the date: 24/06/2024?"

    If possible, can I use a formula or a script, or something easy?"

  • #2
    Hi there,

    I don't believe such a thing exist in the formula functions.
    In PHP, you can use something like this

    PHP Code:
    <?php
    $dateTime 
    = new DateTime();
    $dateTime->setTimestamp('1719240582');

    Comment


    • #3
      Hi BigBoss,

      You can try using the following formula script, but keep in mind that with this option, there is no precision down to the second:
      Code:
      $unixTimestamp = 1712241582;
      
      $days = number\floor($unixTimestamp / 86400);
      $remainingSeconds = $unixTimestamp % 86400;
      $hours = number\floor($remainingSeconds / 3600);
      $remainingSeconds = $remainingSeconds % 3600;
      $minutes = number\floor($remainingSeconds / 60);
      
      $baseDate = '1970-01-01 00:00:00';
      
      $convertedDate = datetime\addDays($baseDate, $days);
      $convertedDate = datetime\addHours($convertedDate, $hours);
      $convertedDate = datetime\addMinutes($convertedDate, $minutes);

      Comment


      • #4
        I will try both possibilities thank you

        Comment

        Working...
        X