Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FreeMarker has a <code>time_zone</code> setting, and it automatically show Java <code>Date</code>-s in that time zone. If it's not set properly in your environment, you can force it in the template like <code>&lt;#setting time_zone="JST"&gt;</code>, but it's kind of ugly to do.</p> <p>If that UTC date-time comes in a string, then first you have to tell FreeMarker to parse that string as a date-time with something like <code>myUTCDate?datetime('yyyy-MM-dd HH:mm:ss')</code>; I can't know what what's the exact pattern in your case. But if it doesn't include the time zone, then you have a bit of trouble here, as it will be interpreted in the <code>JST</code> timezone. In that case you could do <code>(myUTCDate + ' UTC')?datetime('yyyy-MM-dd HH:mm:ss z')</code>. And of course if you do this a lot, you better put this mess into a <code>#function</code>.</p> <p><strong>Update:</strong> There was a mistake in my original answer: it has used <code>hh</code> that means 0-12 hours without <code>a</code>. I have changed that to <code>HH</code>, which is 0-23 hours. Also here's a tests I did. Works fine for me:</p> <pre><code>&lt;#setting time_zone='JST'&gt; &lt;#setting datetime_format='yyyy-MM-dd HH:mm:ss'&gt; Current time (Java Date object): Local time non-ISO: ${.now} UTC ISO: ${.now?iso_utc} Local ISO: ${.now?iso_local} Local ISO without zone: ${.now?iso_local_nz} &lt;#assign myUTCDate = '2010-05-15 10:00:00'&gt; Interperted as local, printed as local: ${myUTCDate?datetime} Interperted as UTC, printed as local: ${(myUTCDate + ' UTC')?datetime('yyyy-MM-dd HH:mm:ss z')} </code></pre> <p>which prints:</p> <pre><code>Current time (Java Date object): Local time non-ISO: 2013-11-10 01:34:00 UTC ISO: 2013-11-09T16:34:00Z Local ISO: 2013-11-10T01:34:00+09:00 Local ISO without zone: 2013-11-10T01:34:00 Interperted as local, printed as local: 2010-05-15 10:00:00 Interperted as UTC, printed as local: 2010-05-15 19:00:00 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload