Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Get the day of the week with PHP

Leer en espanol
Get the day of the week with PHP

Table of contents

First Example: BASHphp< ?php $var= date("w"); switch($var) { case 0: echo "It's Sunday"; break; case 1: echo "It's Monday"; break ===

Two small, very simple examples of how to find the day of the week.

First Example:

BASH
php
< ?php
$var= date("w");
switch($var) {
case 0: echo "Es domingo";
break;
case 1: echo "Es Lunes";
break;
case 2: echo "Es Martes";
break;
case 3: echo "Es Miercoles";
break;
case 4: echo "Es Jueves";
break;
case 5: echo "Es Sabado";
break;
case 6: echo "Es Sabado";
break;
}
?>

Second example:

BASH
php
< ?php

$var= date("w");

if($var == "0" ) {

echo "Es domingo";

} else if ($var == "1" ) {

echo "Es Lunes";

} else if ($var == "2" ) {

echo "Es Martes";

} else if ($var == "3" ) {

echo "Es Miercoles";

} else if ($var == "4" ) {

echo "Es Jueves";

} else if ($var == "5" ) {

echo "Es Viernes";

} else if ($var == "6" ) {

echo "Es Sabado";
}
?>

Regards, rokitoh

:wq!

Comments