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

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 return view in web.php 
Php :: redirect from http to https laravel 
Php :: passing parameters with route keyword in blade laravel 
Php :: make full laravel model ( with migration, controller and resource ) 
Php :: php mongodb 
Php :: php convert print_r to array 
Php :: sorting sql query array by column key php 
Php :: laravel model save get id 
Php :: softdeletes laravel 
Php :: date time in php 
Php :: wp_query post by category taxonomy 
Php :: laravel array cache 
Php :: codeigniter form validation datetime 
Php :: php clear cache 
Php :: php remove control characters from string 
Php :: Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php 
Php :: get post in php 
Php :: check if given date time is of today or yesterday php 
Php :: grouping route in laravel 
Php :: php gethostname 
Php :: json encode 
Php :: php loops 
Php :: convert std to array php 
Php :: ci base url dynamic 
Php :: symnfony bearer token 
Php :: php remove non utf-8 characters 
Php :: php ?? 
Php :: new session php 
Php :: Laravel: Set timestamp column to current timestamp 
Php :: include in php 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =