I want to do this:

if (пятница) {//условие}; 

Ie how to determine the Friday code)

  • one
    I love these questions. And what prevents to do so? - tutankhamun
  • one
    Blessing ... - Alexey Shimansky

2 answers 2

For example:

 if (5 == date('w')) { drinkVodka(); } 

See also date , strftime , getdate

  • correct condition) - Yuri Negometyanov
  • And if (5 == date('w')) { drinkVodka(); } if (5 == date('w')) { drinkVodka(); } only until 1:20 pm of the day and in else { //условие еще } How to do this?) - pwnz22
  • one
    @ pwnz22 Why didn’t you follow the links? For example, getdate returns a structure in which both hours and minutes are, then you can compare it as you like. You can take the time in the form of date('Hi') and compare it with the number 1320 - tutankhamun

Roughly speaking:

 $daysOfWeek = array('monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7); if (date('w') == $daysOfWeek['friday']) { // some code } 

Those. you need to have a variable, or a constant, or a function that will return the day of the week, and then compare the current date with that in the variable / constant / result of the function. And if the condition is true - execute the code.