1. Obtain the number of days in the current month.
Nscalendar * Calendar = [nscalendarcurrentcalendar];
Nsange range = [calendarrangeofunit: nsdaycalendarunitinunit: nsmonthcalendarunitfordate: [nsdatedate];
Nsuinteger numberofdaysinmonth = range.
Thought 1: get the number of the last day of the month. For example, if it is 28 days, there will be 28 days.
Idea 2: deduct the first day of the month from the first day of the next month. For example, "2006-08-01" minus "2006-07-01" indicates the
The PHP computing time period is the day of the week, the day after the current time and the time difference between the date. These time functions have been released. you don't need to use them! If you have any questions, you can leave a message
Copy CodeThe code is as follows:
//Gets the number of days that can be used for any month function getDays ($month, $year) { switch ($month) { Case 4: Case 6: CA SE 9: Case one by one: $days = 30; break; Case 2: if ($year%4==0) { if
This article mainly introduces the method by which PHP obtains the number of days of the month and the date array according to the date, related to the relevant judgment, conversion and the traversal operation of the character and array of PHP, and
This article describes how to calculate the number of days for two different dates in php. The example analyzes the php operation date skills, for more information about how to calculate the number of days for different dates in php, see the example
Test instructions: There is a system, Xiao Ming to find a bug, he can find and find only one bug every day, require gathered up n different bug, and each system to find at least one bug, to complete the task of the expected number of daysAnalysis:Or
CopyCode The Code is as follows: 'returns the total number of days in a year.
Function dayofyear (byval y)
Dayofyear = datepart ("Y", Y & "-12-31 ")
End function5
'Example: Response. Write dayofyear (2012)
Detailed Syntax of ASP datepart Functions
Number of days in the month of the PHP date
Public Function Daysofmonth ($year =null, $month =null) {if ($year ===null) {$year = $this->getpart (' yy ');}if ($month ===null) {$month = $this->getpart (' mm ');}if ($month ==2){if (($year% 4 = = 0 && $
/*** Get the number of days between two dates */
Public static int getdaysbetween (string begindate, string enddate) throws parseexception
{
Simpledateformat format = new simpledateformat ("yyyy-mm-dd ");
Date bdate = format. parse
Java obtains the number of days between dates.
// Obtain the number of days between two datesPrivate int daysBetween (Date now, Date returnDate) {Calendar cNow = Calendar. getInstance (); Calendar cReturnDate = Calendar. getInstance (); cNow.
The general practice is to first determine the number of months, and then determine the number of days (usually with a switch), if it is February, You have to determine whether the selected year is a leap year, then decide whether it is 28 days or 29
PHP converts a date string to an example of the current number of days
Enter as a date string, for example: 2011-3-23
The output is an example of the current number of days, for example: 1
?
The code is:
?
public static function Convertdatetolong
1. Use calendar to get last day of last monthCalendar calendar = Calendar.getinstance ();Calendar.set (Calendar.day_of_month, 1);Calendar.add (Calendar.date,-1);String lastmonthendday = new SimpleDateFormat ("YyyyMMdd"). Format (Calendar.gettime ()
Java based on the time of day to obtain the time between the first 7 days and the number of days after the query timePackage Com.kugou.schedu.service;import Java.text.parseexception;import Java.text.simpledateformat;import Java.util.calendar;import
DescriptionOperating system: CentOSMongoDB installation directory:/usr/local/mongodbMongoDB Database storage directory:/home/data/mongodb/mongodb_dataMongoDB Log storage directory:/home/data/mongodb/mongodb_logPurpose of implementation:Save to the
Problem DescriptionWater problemInputEnter 2 dates, date by month date, month date by symbol-separated (topic contains multiple sets of data)OutputFind the number of days between these 2 dates (excluding itself), one row per group of test dataSample
1. Determine if a leap yearfunction Isleapyear (eDate) { var year = edate.getfullyear (); return (((0 = = year% 4) && (0! = (year% 100))) | | (0 = = year%));}2. Get the total number of days in a monthfunction Getdaysinmonth (eDate) { var
This is a function that calculates the number of days from January 01, 2000 to a specified day(Calculate head also count tail) date format is: YYYY-MM-DD Calculate the number of days from January 01, 2000 to one day function Cal_start2end ($end
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.