“PHP Get Day of Week” Réponses codées

PHP CHECK JOUR DE LA DATE DE LA DATE

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

Comment obtenir la date de début de la semaine en php

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

Obtenez le jour de la date PHP

// Prints the day
echo date("l") . "<br>";
Ankur

PHP Semaine d'une 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.
Misty Mouse

PHP Get Day of Week

date('w'); //gets day of week as number(0=sunday,1=monday...,6=sat)

//note:returns 0 through 6 but as string so to check if monday do this:
if(date('w') == 1){
	echo "its monday baby";
}
Grepper

PHP Obtenez cette semaine de date

$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>";
Grumpy Goshawk

Réponses similaires à “PHP Get Day of Week”

Questions similaires à “PHP Get Day of Week”

Plus de réponses similaires à “PHP Get Day of Week” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code