4👍
If you have a Date
object which is in UTC, you can use your code to display it in a locale and timezone much as you did in your code.
Live demo:
var utcTime = new Date("2020-10-16T18:00:00Z");
console.log('UTC Time: ' + utcTime.toISOString());
var usaTime = utcTime.toLocaleString("en-US", {timeZone: "America/New_York"});
console.log('USA time: '+ usaTime)
So
Do I need to pass the value of created_at into a javascript function that will convert the date?
Yes, assuming your result._source.created_at
value is formatted as a UTC date, you would pass it in and call toLocaleString
to display it appropriately.
Perhaps something like:
<div class="panel-heading">
<p>createdAt:{{ new Date(result._source.created_at).toLocateString("en-US", {timeZone: "America/New_York") }}</p>
</div>
- [Vuejs]-How to call ajax request one time to load data in multiple component instances
- [Vuejs]-Vue nuxt qrcode reader installation
Source:stackexchange.com