how to use the date function to get the first and last date of current month?

And also

how to use the date function to get the first and last date of current year?

how to use the date function to get the first and last date of current quarter?

how to use the date function to get the first and last date of current week?

    There's different ways you can do this. To try to keep
    it dynamic, we'll set the format up front and try to go
    through a couple of the different ways you can go about this.
    We'll use a combination of [man]date[/man], [man]mktime[/man], and [man]strtotime[/man].
    Quarters aren't really a normal thing, and are usually considered fiscal,
    which can be a different calander all together, so hopefully you
    can take these examples and get it yourself.

    $format = "m/d/Y";   // what format to output in
    $year   = date("Y"); // Current year
    $month  = date("m"); // Current month
    
    # Current month
    $first = date($format, mktime(0, 0, 0, $month, 1, $year));
    $last  = date($format, mktime(0, 0, 0, $month, date("t"), $year));
    
    # Current year
    $first = date($format, strtotime($year."-01-01"));
    $last  = date($format, strtotime($year."-12-31"));
    
    # Current week
    /* Guessing Sunday for first, Saturday for last... */
    $first = date($format, strtotime("last Sunday"));
    $last  = date($format, strtotime("this Saturday"));
    
      Write a Reply...