How do I format .created_at to produce the same time format as my Ruby code?
Javascript / jQuery
<script>
setInterval(function () {
fetch('/pages/markets.json')
.then((response) => response.json())
// .then((data) => console.log(data))
.then((data) => {
$('#container').html('')
data.forEach((item) => {
$('#container').append('<li><div id="created" class="text-xs mb-1">' + item.created_at + '</div><div id="text" >' + item.tweet_text +'</div></li>')
})
});
}, 10000);
</script>
Returns: 2022-08-15T13:55:32.089Z
Ruby on Rails
t.created_at.in_time_zone("Eastern Time (US & Canada)").strftime('%I:%M %p')
Returns: 01:30 PM