[SOLVED] Get today's date in script using JQuery
Posted: Wed Feb 21, 2018 6:13 pm
Hi, I have made a lot of customizations in our script, embedded succesfully lot of JS code in vicidial.php file. The only thing that actually can not manage to obtain is to get today's date in a date input inside a form.
and in the vicidial.php file
i do need that for passing data in a google sheet. It's not working for me, any help?
- Code: Select all
<input class="w3-input" type="text" name="date" id="date" readonly/>
and in the vicidial.php file
- Code: Select all
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
$(document).ready(function() {
var date = new Date();
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
var today = year + "-" + month + "-" + day;
$("#date").attr("value", today);
});
i do need that for passing data in a google sheet. It's not working for me, any help?