Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php check weekday of date

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

how to get week start date in php

$firstday = date('l - d/m/Y', strtotime("this week"));
echo "First day of this week: ", $firstday;
Comment

php get this week date range

$monday = strtotime('last monday', strtotime('tomorrow'));
$sunday = strtotime('+6 days', $monday);
echo "<P>". date('d-M-Y', $monday) . " to " . date('d-M-Y', $sunday) . "</P>";
Comment

week day php

date('l'); //Returns full day name of the week: Thursday
date('D'); //Returns abbreviated day name of the week: Thu
Comment

php week of a date


Things to be aware of when using week numbers with years.

<?php
echo date("YW", strtotime("2011-01-07")); // gives 201101
echo date("YW", strtotime("2011-12-31")); // gives 201152
echo date("YW", strtotime("2011-01-01")); // gives 201152 too
?>

BUT

<?php
echo date("oW", strtotime("2011-01-07")); // gives 201101
echo date("oW", strtotime("2011-12-31")); // gives 201152
echo date("oW", strtotime("2011-01-01")); // gives 201052 (Year is different than previous example)
?>

Reason:
Y is year from the date
o is ISO-8601 year number
W is ISO-8601 week number of year

Conclusion:
if using 'W' for the week number use 'o' for the year.
Comment

php get day of week number

echo date('d', strtotime('2022-02-02')); // 02
echo date('j', strtotime('2022-02-02')); // 2
Comment

PREVIOUS NEXT
Code Example
Php :: laravel translation parameter send 
Php :: laravel disable logging 
Php :: isset in php 
Php :: php using composer autoload 
Php :: financial year calculation in php 
Php :: laravel redis sentinel 
Php :: Laravel get all parent categories for each category 
Php :: Laravel Google Line Chart 
Php :: php ternary string 
Php :: get object value by key php 
Php :: php else 
Php :: laravel filesystem 
Php :: run queue after x minutes laravel 
Php :: php for loop stack overflow 
Php :: causes of class not found in laravel 
Php :: curl failed laravel centos 
Php :: confirm popup laravel 
Php :: extend multiple classes in php 
Php :: shortcode wordpress form 
Php :: array_filter in php 
Php :: php RFC3339 
Php :: taxonomy-{taxonomy-slug}.php 
Php :: laravel env use other env variables 
Php :: What was the old name of PHP? 
Php :: send gmail 
Php :: php fn closure 
Php :: laravel project composer [ErrorException] Undefined index: name 
Php :: php form validation 
Php :: php ternary operator good example 
Php :: laravel rules 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =