I was wondering how I would go about converting the SQL timestamp format (2016-04-30T01:19:45.000Z) to a standard date format like (30/04/2016) using Javascript/front-end-technology.
Thanks in advance.
Hope this helps. This can be achieved in multiple ways - pure JavaScript, jQuery, Angular etc., As well it requires bit of tweaking based on your requirement. Do let me know if this helps
<script>
var myDate = new Date('2010-10-11T00:00:00+05:30');
alert((myDate.getMonth() + 1) + '/' + myDate.getDate() + '/' + myDate.getFullYear());
</script>
It depends on how many operations you want to do. If it is more than one, then i would recommend using a library like momentJS. It makes timestamp conversion very simple. See example below.
MySQL date string:
var sqlDate = new Date('2016-04-30T01:19:45.000z');
var now = moment(sqlDate).format('l');
console.log( now );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With