Home  >  Article  >  Backend Development  >  php gets the day of the week that today or a certain date is

php gets the day of the week that today or a certain date is

WBOY
WBOYOriginal
2016-07-25 08:41:58936browse

Effect: Today is: Friday Today is: Friday 2010-12-12 is: Sunday

[PHP] code

  1. function getWeekName($data,$format = 'week')
  2. {
  3. $week = date( "D ",$data);
  4. switch($week)
  5. {
  6. case "Mon ":
  7. $current = $format."一";
  8. break;
  9. case "Tue ":
  10. $current = $format."二";
  11. break;
  12. case "Wed ":
  13. $current = $format." three";
  14. break;
  15. case "Thu ":
  16. $current = $format."four";
  17. break;
  18. case "Fri ":
  19. $current = $format."five";
  20. break;
  21. case "Sat ":
  22. $current = $format."六";
  23. break;
  24. case "Sun ":
  25. $current = $format."日";
  26. break;
  27. }
  28. return $current;
  29. }
  30. echo 'Today It is: '.getWeekName(time(),'week');
  31. echo '
    ';
  32. echo 'Today is: '.getWeekName(time(),'week');
  33. echo '
    ';
  34. echo '2010-12-12 is: '.getWeekName(strtotime('2010-12-12'),'week');
  35. ?>
Copy code
php


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn