Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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 :: replace in php 
Php :: php unique id 
Php :: laravel where and or condition 
Php :: Installing PHP and Configuring Nginx to Use the PHP Processor 
Php :: update role spatie 
Php :: open json file php 
Php :: multiple logical condition in laravel query 
Php :: how make custom menu in wordpress 
Php :: php echo sql result 
Php :: ternary operator for three conditions in php 
Php :: wp get post id by slug 
Php :: create if not exist laravel 
Php :: php catch exception 
Php :: get request data in observer laravel 
Php :: php server function 
Php :: every wordpress page redirect to localhost ? 
Php :: php do not refresh page after submit post 
Php :: custom laravel auth 
Php :: how to run multiple seeder at a time in laravel 
Php :: how unique field in table in phpmyadmin 
Php :: how to get ip address of pc in php 
Php :: how to change php version in cpanel 
Php :: remove a specific element from an array php 
Php :: how to convert unix timestamp to date php 
Php :: php trim quotes 
Php :: php html to text 
Php :: limiting requests to controllers in laravel 
Php :: array of dates laravel 
Php :: format a number with leading zeros in php 
Php :: how to get ip address of client in php 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =