1

In ColdFusion, using GetTimeZoneInfo() methods, we can get utcoffset time based on the server current date and time, but as per my requirement for the given date like 2020-06-23 21:03:37, the utcoffset should be given as "5", for now it is "4",

Please suggest in ColdFusion 9 version and also I want to know the client OS date offset, but found that cfm is server side, so not support this.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Prabha
  • 266
  • 4
  • 25
  • 1
    using dateConvert( "local2utc", '2019-12-23 01:03:37' ), I got 2019-12-23 06:03:37, as 5 hours utc offset , this code run in est time zone server , the other unknown thing is to get the time zone of the local system time setting or client time, is there any chance to get the system time other than javascript variables in coldfusion. – Prabha Jun 23 '20 at 21:51

1 Answers1

1

Getting the time zone requires client side code, aka Javascript. If I had jQuery at my disposal, I would consider

<script>
$( document ).ready(function() {
    d = new Date();
    n = d.getTimezoneOffset();

    $("#offset").val(n);
});
<script>


<form>
   ...
   <input type="hidden" name="offset" id="offset>
   ...
</form>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • Hi James, thank you for the reply, but I achieved the same way you mentioned through Javascript ajax call, want to know whether it can be done through cfm code. – Prabha Jun 24 '20 at 05:03
  • Your question might be a duplicate of this: https://stackoverflow.com/questions/13/determine-a-users-timezone – James A Mohler Jun 24 '20 at 05:38
  • 2
    Getting the user's time of day cannot be done using CF code only. – Dan Bracuk Jun 24 '20 at 12:13