I am trying to retrieve which day of the month it is.
Such as today is August 29,2011.
What i would like to do is just get the days number such as 29, or 30. Which ever day of the month it is.
How would i go about doing this?
To get the day of the month, use the getDate() method. JavaScript date getDate() method returns the day of the month for the specified date according to local time. The value returned by getDate() is an integer between 1 and 31.
getDate() getDate() is an date method in JavaScript, which is used to return the day of the month (between 1 to 31) for the specified date. This method does not have any parameters.
You'll want to do get a Calendar instance and get it's day of month
Calendar cal = Calendar.getInstance(); int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); String dayOfMonthStr = String.valueOf(dayOfMonth);
You can also get DAY_OF_WEEK, DAY_OF_YEAR, DAY_OF_WEEK_IN_MONTH, etc.
The following method would help you in finding day of any specified date :
public static int getDayOfMonth(Date aDate) { Calendar cal = Calendar.getInstance(); cal.setTime(aDate); return cal.get(Calendar.DAY_OF_MONTH); }
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