Welcome Guest, Not a member yet? Register   Sign In
date / time help
#1

hello, i have something this but dont know how make it for month *check/reset every month, (i tried something but i don't know how test it, cannot wait for end of month) can someone help me remake it for months? (reset every month) Angel

Code:
public function getWeekStartEnd()
    {
           $ts = time();
        

        if (date('w', $ts) == 1)
        {
            $start = strtotime('today', $ts);
        }
        else
        {
            $start = strtotime('this week last monday', $ts);
        }
    
        if (date('w', $ts) == 0)
        {
            $end = strtotime('today', $ts);
        }
        else
        {
            $end = strtotime('this week next sunday', $ts);
        }
        
     
        return array(date('Y-m-d H:i', $start), date('Y-m-d H:i', $end + 60*60*23 + 60*59));
    }
Reply
#2

(This post was last modified: 03-22-2019, 02:45 PM by Wouter60.)

Maybe this is helpful:

To find the first day of the current month:
PHP Code:
$d = new DateTime('first day of this month');
echo 
$d->format('Y-m-d'); 

To find the last day of the current month:
PHP Code:
$d = new DateTime('last day of this month'); 
echo 
$d->format('Y-m-d'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB