View day of the week as date used in PHP query

Asked

Viewed 867 times

0

Good afternoon everyone, I’m having a question on a course project. I have a form where I look for scheduled patients on a certain day of the month.

When I perform the appointment to present the scheduled patients, I must also present what would be the day of the week, that day of the month used in select. The date format is in the "day/month/year".

How could I do that?

  • 2

    To display the day of the week you can use D when formatting the date. echo date("D", strtotime("20/12/2017")); http://br.php.net/manual/en/function.date.php

  • The example you sent me worked in part, I need it to be dynamic. I receive the date that will be used in the query in the following variable "$p_data" based on that date I need to display the day of the week.

  • You just pass the variable to the function strtotime($variable)

  • Thank you very much, the solution worked!

1 answer

3

You can use the following PHP function:

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

Being as follows:

echo date("D", strtotime("20/12/2017"));

There are other formats like:

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.

References: Date function(), strtotime function().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.