We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

# Date & time problem

on
Medium Priority
191 Views
Hi Experts!

I have a small problem which I don't know how to tackle.

If the current date and time is between thursday 21:00 - friday 06:00 {
echo 'thursday';

} else if { the current date and time is between friday 21:00 - saturday 06:00 {
echo 'friday';

} else if { the current date and time is between saturday 21:00 to saturday 06:00 {
echo 'saturday';

} else { echo 'other'; }

How do I rewrite the text to php? I hope you understand :-)

Comment
Watch Question

## View Solution Only

Sr. System Analyst
CERTIFIED EXPERT

Commented:
http://www.php.net/manual/en/function.date.php

string date ( string \$format [, int \$timestamp ] )

w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
D A textual representation of a day, three letters Mon through Sun
G 24-hour format of an hour without leading zeros 0 through 23
H 24-hour format of an hour with leading zeros 00 through 23

Sr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
Sr. System Analyst
CERTIFIED EXPERT

Commented:
here it is
``````\$w = date("w");
\$h = date("G");

echo "W : ".\$w." H:".\$h;

if (((\$w==0) and (\$h>21)) or ((\$w==1) and (\$h<6))) echo "Monday";
if (((\$w==1) and (\$h>21)) or ((\$w==2) and (\$h<6))) echo "Tuesday";
if (((\$w==2) and (\$h>21)) or ((\$w==3) and (\$h<6))) echo "Wednesday";
if (((\$w==3) and (\$h>21)) or ((\$w==4) and (\$h<6))) echo "Thursday";
if (((\$w==4) and (\$h>21)) or ((\$w==5) and (\$h<6))) echo "Friday";
if (((\$w==5) and (\$h>21)) or ((\$w==6) and (\$h<6))) echo "Saturday";
if (((\$w==6) and (\$h>21)) or ((\$w==0) and (\$h<6))) echo "Sunday";
``````
Sr. System Analyst
CERTIFIED EXPERT

Commented:
or this

``````\$w = date("w");
\$h = date("G");

//echo "W : ".\$w." H:".\$h;

if (((\$w==3) and (\$h>21)) or ((\$w==4) and (\$h<6))) echo "Thursday"; else
if (((\$w==4) and (\$h>21)) or ((\$w==5) and (\$h<6))) echo "Friday"; else
if (((\$w==5) and (\$h>21)) or ((\$w==6) and (\$h<6))) echo "Saturday"; else
echo "Other";
``````

Commented:
Thank you HainKurt, that was exactly what I was looking for :-)
Unlock the solution to this question.