Change UTC date time to local date time in javascript/jquery

// php code to get current UTC date time
$utcDateTime = date('Y-m-d h:m:s');

<script src=""></script>

<script src=""></script>
$(document).ready(function() {
var utcDateTime = '<?php echo $utcDateTime; ?>';

var dateTime = moment.utc(utcDateTime).toDate();
var localDateTime = moment(dateTime).format('YYYY-MM-DD HH:mm:ss');

UTC : <div id="utc_date_time"></div></br>
Local: <div id="local_date_time"></div>

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *