用PHP转换漂亮的日期
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用PHP转换漂亮的日期相关的知识,希望对你有一定的参考价值。
This takes a date like so: Sat, 08 Jan 2011 from a database and allows you to use it in your code. For example if you wanted to work out a week from Sat, 08 Jan 2011 it can be done with ease. I created this for a project i am currently working on. There maybe an easier way to deal with this problem but its works so enjoy!
<?php function scheduleGameForNextWeek($date) { switch($month) { case "jan": $month = "01"; break; case "feb": $month = "02"; break; case "mar": $month = "03"; break; case "apr": $month = "04"; break; case "may": $month = "05"; break; case "jun": $month = "06"; break; case "jul": $month = "07"; break; case "aug": $month = "08"; break; case "sep": $month = "09"; break; case "oct": $month = "10"; break; case "nov": $month = "11"; break; case "dec": $month = "12"; break; default: $month = "00"; break; } } $date = "Sun, 9 Jan 2011"; echo $newDate = scheduleGameForNextWeek($date); ?>
以上是关于用PHP转换漂亮的日期的主要内容,如果未能解决你的问题,请参考以下文章