0👍
Convert the stored dateTime to epoch while sending in response.
How you can convert dateTime to epoch there are many ways(send dateTime in epoch in response).
Add in your Model
protected $casts = ['datetime_field' => 'timestamp']
add this method in Laravel class from where you are sending response
protected function toEpoch($datetime )
{
if (gettype($datetime) == 'string') {
$datetime = new DateTime($datetime);
return Carbon::instance($datetime)->format('U');
} else if ($datetime instanceof Carbon) {
return $datetime->format('U');
} else if ($datetime != null) {
return Carbon::instance($datetime)->format('U');
}
}
}
In vue project
{{new Date(epoch*1000)}}
Source:stackexchange.com