Getting current date and time in JavaScript

.getMonth() returns a zero-based number so to get the correct month you need to add 1, so calling .getMonth() in may will return 4 and not 5. So in your code we can use currentdate.getMonth()+1 to output the correct value. In addition: .getDate() returns the day of the month <- this is the one you want .getDay() is a separate method of the Date object which will return … Read more

What is the meaning of || in javascript?

This is the logical OR operator in JS (and most other languages). It is defined in the spec at 11.11. As noted in the spec, expressions on either side will be evaluated first and the logical OR is left-to-right associative. Note that evaluation of the operands follows standard ToBoolean semantics from section 9.2, so [null, undefined, 0, ”] all count … Read more

Obtain form input fields using jQuery?

Thanks to the tip from Simon_Weaver, here is another way you could do it, using serializeArray: Note that this snippet will fail on <select multiple> elements. It appears that the new HTML 5 form inputs don’t work with serializeArray in jQuery version 1.3. This works in version 1.4+