Both of these functions return a DateTime object, so you can output the date in any format available to the PHP date() function. As we’ll create a DateTime object from the date, in the first line, we used the date as second parameter as the matching formatting string in the first parameter. There is a setISODate() method with DateTime extension that accepts the year (4-digit year) and ISO week number. That is to get the first day (Sunday) of a week need to get the Sunday of previous week and to get the first day (Sunday) of next week need to get the Sunday of this week and so on. I uses PHP strtotime to subtract days to the current date. Method 1: Using date () function to retrieve current month PHP’s date () function can let you know date and time related information based on the formatting characters it takes in its first parameter. The function can take maximum of two parameters. We have to deal with strtotime, formatting issues, lots of calculations, and more.. This tutorial will help you to get current date time in PHP. Java Program to get day of week for the last day of each month in 2019; How to get first day of week in PHP? Just use the powerful date () function that takes a format string and an optional unix timestamp as arguments. , PHP provides a ready made DateTime class to solve date time related issues quickly. Input: date = "02/01/2019" Output: 1 Explanation: We can check from the calendar that 2nd January 2019 lies in 1st week of 2019. I’ve changed the date string to “2012-01-21”. Using the DateTime class, we can get the day number of the current date in following steps-, Using the DateTime class to get the day number of any date follow the steps below-. Number 0 will be returned for Sunday and 1 for Monday. In this PHP tutorial, I will tell you how to get start date and end date from week number and year. "\n"; ?> Sample Output: Number of days for the month of Jul is :31 N.B. Sample Solution: