In my script tag, var today
shows in the Sat Sep 07 2019 00:00:00 GMT+0530 (India Standard Time)
date format, and I want to change this date format to the yyyy-mm-dd
format.
My code:
<script>
$(document).ready(function() {
var date = new Date();
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
console.log(today);
});
</script>
I am trying like this:
<script>
$(document).ready(function() {
var date = new Date();
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
var newDate = "<?php echo date("Y-m-d", strtotime(today)); ?>";
console.log(newDate);
});
</script>
How can I change date format using strtotime()
?