How can I get day of given date using jQuery? In c# I do it like this
if(MyDate.DayOfWeek == DayOfWeek.Sunday)
How can i do this in jQuery?
You can do it like that: var d = new Date(); var month = d. getMonth()+1; var day = d.
Javascript date getDay() method returns the day of the week for the specified date according to local time. The value returned by getDay() is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.
get current date in jquery in dd/mm/yyyy format” Code Answer. var mm = String(today. getMonth() + 1).
Call the getDay() method on the Date object to get the day of the week. The getDay method returns the day of the week for the specific date, represented as an integer between 0 and 6 , where 0 is Sunday and 6 is Saturday.
You could use JavaScript's Date.getDay()
$(document).ready(function() {
var d = new Date();
alert(d.getDay());
} );
As stated you don't need jQuery to use this but I've wrapped it in jQuery for your pleasure. As stated by nc3b the result its 0 based where 0 is Sunday.
Using javascript, you can find the day of week: Date.getDay();
Say you have something like this:
Date d = new Date(...);
d.getDay(); // returns day of week.
Careful as it's zero-based so it will return from 0 to 6.
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