<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

How to Convert the Time.now() Value in Seconds Only in Okta

Lifecycle Management
Okta Classic Engine
Okta Identity Engine

Overview

This article details the Okta expressions to convert theTime.now() value in seconds only.

Applies To

  • Okta Expression Language(OEL)
  • Okta Classic Engine
  • Okta Identity Engine (OIE)
  • Lifecycle Management

Solution

In order to convert the Time.now() value to calculate the time in seconds only,  the following expression can be used:

Convert.toInt(String.substring(Time.now("EST", "YYYY-MM-dd HH:mm:ss"),11,13)) * 3600 +
Convert.toInt(String.substring(Time.now("EST", "YYYY-MM-dd HH:mm:ss"),14,16)) * 60 +
Convert.toInt(String.substring(Time.now("EST", "YYYY-MM-dd HH:mm:ss"),17,19))

 
A simpler way may be to convert into unix time format. The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC.

Time.fromIso8601ToUnix(Time.now("EST"))
Loading
Okta Support - How to Convert the Time.now() Value in Seconds Only in Okta