Detect date used with PHP

Asked

Viewed 37 times

-3

How do I detect through php the date of the user? I mean, I know how to track the date, but comparing it to the server date, so it’s not right because of the different time zones. I leave down my code:

<?PHP
    $current = date("d/m");
    $date    = "14/02";
    if ($current == $date){
        echo “qualquer coisa”;
    }
?>
  • You cannot capture the user date through PHP.

  • So that’s not possible?

  • Directly no. You will only get this date using JavaScript. In the php only possible using POG (gambiarra-oriented programming). You can take the IP and, through it, search for the information of which city/state or country it is accessing, then you will get the date.

1 answer

0

  • But this information is related to the server, not the user. If I am in Brazil and the server in the US, the result will be wrong.

Browser other questions tagged

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