Reputation: 489
Here are some of the javascript libraries & css files being used on my project that pertain to date, time, calendar,etc.:
<link rel="stylesheet" href="plugins/bootstrap-datepicker/css/datepicker3.css" />
<link href="plugins/datepicker/jquery.datetimepicker.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js" type="text/javascript"></script>
<script src="../plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="../plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="../plugins/datepicker/jquery.datetimepicker.js" type="text/javascript"></script>
In one of my ASPX pages, I have the following JavaScript code:
var d = new Date();
var startdate = d.format("MM/dd/yyyy");
var enddate = d.format("MM/dd/yyyy");
I've been trying to resolve the following error by searching the internet for various JavaScript libraries that pertain to date, time, calendar, etc., and then adding the said libraries to my project, and referring to them in the ASPX page:
Uncaught TypeError: d.format is not a function
However, None of the references to the libraries seem to work.
Could someone please tell me which javascript library I should reference in order to remove the aforementioned error?
Upvotes: 0
Views: 64
Reputation: 11
parseDate(String(d.year));
or
parseDate(d.year.toString());
However, keep in mind that the same result – a Date object – could be achieved natively, like this:
var date = new Date(d.year, 0);// The required 0, is for January
Upvotes: 0
Reputation: 133403
As you are already referencing moment use its format()
function
var startdate = moment(d).format("MM/DD/YYYY")
var d = new Date();
snippet.log(moment(d).format("MM/DD/YYYY"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js" type="text/javascript"></script>
<!-- Provides the `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->
<script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
Upvotes: 1