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 :: calculate total time from start and end datetime in php 
Php :: php validate file type 
Php :: how to create laravel project 
Php :: php get file location 
Php :: laravel pluck relationship 
Php :: php value to javascript variable laravel blade 
Php :: number format without comma php 
Php :: sitemap for php website 
Php :: check if the link is image or url php 
Php :: laravel collection pluck 
Php :: wp query search 
Php :: how to remove keys in subarray php 
Php :: how to use php to print inside html 
Php :: php trim quotes 
Php :: heredoc php 
Php :: Redirect to external domain in Laravel 
Php :: send email in php 
Php :: laravel-cors 
Php :: doctrine query builder order by multiple 
Php :: join array of strings php 
Php :: reCAPTCHA v3 PHP 
Php :: how to send html table in email body in php 
Php :: - root composer.json requires php ^7.2 but your php version (8.0.1) does not satisfy that requirement. 
Php :: hide all error in php 
Php :: concat php 
Php :: wordpress create shortcode 
Php :: get nearby from longitude and latitude in laravel 
Php :: uninstall phpstorm ubuntu 
Php :: Laravel stop on first validation error 
Php :: Adding JavaScript to a Specific WordPress Page Using Code In Header 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =