In API integration, I am generating JWT token in that, time is used as iat converted in epoch time.
I am trying to get epoch time in d365 finance and operations. while i try to convert it in Dev machine it is working fine, but in production server it is giving wrong time also in UAT server it is not giving the correct output.
I have set same timezone for user in both Production , UAT and Dev box
below is the code:
internal final class EpochTime
{
public static void main(Args _args)
{
System.DateTime dateTime2 = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone());
str epochTime = any2str(EpochTime::getUnixTime(dateTime2));
Info(epochTime);
}
public static int64 getUnixTime(System.DateTime dateTimeValue)
{
return new System.DateTimeOffset(dateTimeValue).ToUnixTimeSeconds();
}
}