snipt

Ctrl+h for KB shortcuts

PHP

PHP timezone conversion in one line

echo date_create($userDate)->setTimezone(new DateTimeZone($userTimezone))->format(‘Y-m-d H:i’);
https://snipt.net/embed/ed38aeb4d135e83f4509982bc13ab8e9/
/raw/ed38aeb4d135e83f4509982bc13ab8e9/
ed38aeb4d135e83f4509982bc13ab8e9
php
PHP
1
2019-06-04T02:38:00
True
False
False
/api/public/snipt/17200/
timezone-conversion-from-servers-timezone-to-users-in-one-line
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">echo date_create($userDate)-&gt;setTimezone(new DateTimeZone($userTimezone))-&gt;format(‘Y-m-d H:i’);</span> </span></pre></div> </td></tr></table>
conversion, php, time, timezone