Home
Analytics
Displaying Time in correct Time Zone for user
dan3874
I have deployed a report on a server (not iServer) that is set to eastern time. We call that report with an HTML link from multiple sites across the US in various time zones. However, the date/time stamp for when the report is run, new Date(), displays the date/time of the server. I want to be able to send an offset in the calling link to adjust that date/time to the local time of the user.
Any help would be appreciated!
Find more posts tagged with
Comments
mwilliams
Hi Dan,
You could pass the timezone from the client in with the URL parameter __timezone.
dan3874
That's the easy part, I can pick a parameter name and send in the time zone. I have some questions about how to implement it though.
1) What format should I pass in, CST or -6?
2) How do I use that in the report to change the timezone as it displays?
3) How do I apply that to the "new Date()" as it displays on the page footer since it has no built in formatting?
Thanks,
mwilliams
Dan,<br />
<br />
Here's an example of how you can manipulate the dateTime value in the report footer. I passed in a parameter with both the offset and the timezone letters, i.e. -8PST. I then used a BIRT dateTime function to subtract the appropriate hours based on the server's timezone, formatted the date how I wanted it within the text box, and then added the timezone letters to the date (also within the text box).<br />
<br />
Report designed in 2.6.0<br />
<br />
Here is the final contents of my text box in the master page footer for the date.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<value-of format="MM/dd/yyyy hh:mm:ss a ">currentOffset = -6;
clientOffset = parseInt(params["TZOffset"].substr(0,2));
offsetDifference = clientOffset - currentOffset;
BirtDateTime.addHour(new Date(), offsetDifference);</value-of><VALUE-OF>params["TZOffset"].substr(2,3);</VALUE-OF>
</pre>
<br />
Hope this helps.
dan3874
Thank you for this, it is simple and to the point!
rihanna
Hi Everyone!
Is there a way to get a time zone similar to reportContext.getAppContext().get("ServerUserName")? I need to access the time zone value chosen by the Actuate portal user.
thuston
I know this is an old post, but I recently solved this and thought I'd update.<br />
<br />
Use this in the OnRender and it should update the control to show the User's desired TimeZone ( In 11Sp1 / BIRT 2.6.2 ).<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var tz = reportContext.getAppContext().get("AppRuntimeTimeZone");
if ( tz == null )
tz = java.util.TimeZone.getDefault();
var dfmt = new java.text.SimpleDateFormat("MMMM dd, yyyy H:mm:ss a z");
dfmt.setTimeZone(tz);
this.setDisplayValue( dfmt.format(this.getValue()) );</pre>
Dinu
Hi everyone,
I am facing the same issue...I have tried the above solution but it not working.
I am using BIRT 2.3.1
I have to display Date Time in the footer of page according to the user local machine date time now it is showing MAXIMO server date and time.
Please help ..its very urgent for me.
Thanks in advance.any help would be appreciated.
yrraja
Is it possible to change the timezone in the report context so that everything else picks it up and shows the report in desired timezone?
Thanks
mwilliams
<p>In the initialize method, you can set the offset with this:</p>
<p> </p>
<p>reportContext.getTimeZone().rawOffset = offset.</p>
<p> </p>
<p>It's in ms, so you'll need to take that into account.</p>
Siva Rao
<p>I have a parameter StartTime in my report.</p>
<p>It gives output as a string.How can i convert a string to time format in BIRT report?</p>