php中时间日期格式化函数

这里我们介绍了几个函数时间日期格式化全部都是自定的以还有一个星期格式,有需要的朋友可以参考一下,代码如下:

  1. function format_date( $STRING1 )
  2. {
  3. $STRING1 = str_replace( "-0", "-", $STRING1 );
  4. $STR = strtok( $STRING1, "-" );
  5. $STRING2 = $STR."年";
  6. $STR = strtok( "-" );
  7. $STRING2 .= $STR."月";
  8. $STR = strtok( " " );
  9. $STRING2 .= $STR."日";
  10. return $STRING2;
  11. }
  12. function format_date_short1( $STRING1 )
  13. {
  14. $STRING1 = str_replace( "-0", "-", $STRING1 );
  15. $STR = strtok( $STRING1, "-" );
  16. $STRING2 = $STR."年";
  17. $STR = strtok( "-" );
  18. $STRING2 .= $STR."月";
  19. return $STRING2;
  20. }
  21. function format_date_short2( $STRING1 )
  22. {
  23. $STRING1 = str_replace( "-0", "-", $STRING1 );
  24. $STR = strtok( $STRING1, "-" );
  25. $STR = strtok( "-" );
  26. $STRING2 .= $STR."月";
  27. $STR = strtok( " " );
  28. $STRING2 .= $STR."日";
  29. return $STRING2;
  30. }
  31. function format_date_short3( $STRING1 )
  32. {
  33. $STRING1 = str_replace( "-0", "-", $STRING1 );
  34. $STR = strtok( $STRING1, "-" );
  35. $STRING2 .= $STR."年";
  36. return $STRING2;
  37. }
  38. function format_date_number( $STRING1 )
  39. {
  40. $STRING1 = str_replace( "-0", "-", $STRING1 );
  41. $STR = strtok( $STRING1, "-" );
  42. $STRING2 = $STR;
  43. $STR = strtok( "-" );
  44. $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
  45. $STR = strtok( " " );
  46. $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
  47. return $STRING2;
  48. }
  49. function get_week( $STRING )
  50. {
  51. switch ( date( "w", strtotime( $STRING ) ) )
  52. {
  53. case 0 :
  54. return "日";
  55. case 1 :
  56. return "一";
  57. case 2 :
  58. return "二";
  59. case 3 :
  60. return "三";
  61. case 4 :
  62. return "四";
  63. case 5 :
  64. return "五";
  65. case 6 :
  66. return "六";
  67. }
  68. }