UTCNow Timestamp Format and Conversion Expression
In Bold Reports, there is an option to include a UTC (Coordinated Universal Time) timestamp. UTC is a global standard time reference used across different time zones, ensuring consistency in time representation. By incorporating a UTC timestamp, synchronize and compare time data accurately, making it particularly useful for applications that involve multiple geographical locations. A particular timezone(IST) is converted to UTC timezone also.
Use the following expressions and formatting options to add a UTC timestamp to your report.
-
Getting the UTC time:
To get the current UTC time, use the following expression:
=Now.ToUniversalTime()
-
Formatting the UTC time:
To format the UTC time in a specific way, use the Format function. The following example demonstrates formatting the UTC time as “yyyy-MM-dd HH:mm:ss UTC”:
=Format(Now.ToUniversalTime(), "yyyy-MM-dd HH:mm:ss UTC")
-
Convert IST timezone to UTC timezone:
To convert the IST timezone to UTC timezone, add the following code in code modules and convert it. Follow these steps:- Add the following code in code modules in your report.
Function ConvertToUtc(dateTime As DateTime) As DateTime Return TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, "India Standard Time", "UTC") End Function
- Drag and drop a text box and add the following expression. Click “OK,” save, and preview the report. The current IST time will be converted to UTC time.
=Code.ConvertToUtc(Now())
- Add the following code in code modules in your report.
By incorporating these expressions into your report, you will be able to include the UTC timestamp as per your requirements.