Question

Epoch Seconds Conversion in AA

  • 13 February 2023
  • 5 replies
  • 165 views

Badge +5

Hi Developers,

I am trying to convert a specific date into epoch seconds in AA. However, that option is not available in the Datetime Action. Is there any alternate or shortcut way we can achieve this? 
 


5 replies

Badge

Hello @Kayal 2500 
Please provide an example of your problem, that is what will be the initial value and what is the target value you want to achieve?

Thanks!!

Badge +5

Hi @shibashis001 

 

The date will be in this format : 13 Feb 2023 14:05:16

And the output should be like this in epoch seconds conversion : 1676297116

Badge +1

Use the below JavaScript to get the epoch time. You need to replace the below date with your required date.

 

function ConvertToEpoch()
{
return Math.floor(new Date('12/2/2022').getTime()/1000.0)
}

Userlevel 6
Badge +16

Hi @Kayal 2500

There is no Inhouse package as of now, same can be achieved using any scripting languages like python or c#. Checkout below code in python

import time

date_str = "13 Feb 2023 14:05:16"
pattern = "%d %b %Y %H:%M:%S"
epoch_time = int(time.mktime(time.strptime(date_str, pattern)))
print(epoch_time)
 

Userlevel 5
Badge +9

@Kayal 2500

An approach additional to above is using an online converter like :

https://www.freeformatter.com/epoch-timestamp-to-date-converter.html

HTH

Regards

Reply