php get today day of week code example

Example 1: php check weekday of date

$dayofweek = date('w', strtotime($date));
$result    = date('Y-m-d', strtotime(($day - $dayofweek).' day', strtotime($date)));

Example 2: week starting date and end date in php

<?php$week=29;$year=2017;function getStartAndEndDate($week, $year) {  $dateTime = new DateTime();  $dateTime->setISODate($year, $week);  $result['start_date'] = $dateTime->format('d-M-Y');  $dateTime->modify('+6 days');  $result['end_date'] = $dateTime->format('d-M-Y');  return $result;}$dates=getStartAndEndDate($week,$year);print_r($dates);?>

Tags:

Php Example