php中时间日期格式化函数
这里我们介绍了几个函数时间日期格式化全部都是自定的以还有一个星期格式,有需要的朋友可以参考一下,代码如下:
- function format_date( $STRING1 )
- {
- $STRING1 = str_replace( "-0", "-", $STRING1 );
- $STR = strtok( $STRING1, "-" );
- $STRING2 = $STR."年";
- $STR = strtok( "-" );
- $STRING2 .= $STR."月";
- $STR = strtok( " " );
- $STRING2 .= $STR."日";
- return $STRING2;
- }
- function format_date_short1( $STRING1 )
- {
- $STRING1 = str_replace( "-0", "-", $STRING1 );
- $STR = strtok( $STRING1, "-" );
- $STRING2 = $STR."年";
- $STR = strtok( "-" );
- $STRING2 .= $STR."月";
- return $STRING2;
- }
- function format_date_short2( $STRING1 )
- {
- $STRING1 = str_replace( "-0", "-", $STRING1 );
- $STR = strtok( $STRING1, "-" );
- $STR = strtok( "-" );
- $STRING2 .= $STR."月";
- $STR = strtok( " " );
- $STRING2 .= $STR."日";
- return $STRING2;
- }
- function format_date_short3( $STRING1 )
- {
- $STRING1 = str_replace( "-0", "-", $STRING1 );
- $STR = strtok( $STRING1, "-" );
- $STRING2 .= $STR."年";
- return $STRING2;
- }
- function format_date_number( $STRING1 )
- {
- $STRING1 = str_replace( "-0", "-", $STRING1 );
- $STR = strtok( $STRING1, "-" );
- $STRING2 = $STR;
- $STR = strtok( "-" );
- $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
- $STR = strtok( " " );
- $STRING2 .= strlen( $STR ) == 1 ? "0".$STR : $STR;
- return $STRING2;
- }
- function get_week( $STRING )
- {
- switch ( date( "w", strtotime( $STRING ) ) )
- {
- case 0 :
- return "日";
- case 1 :
- return "一";
- case 2 :
- return "二";
- case 3 :
- return "三";
- case 4 :
- return "四";
- case 5 :
- return "五";
- case 6 :
- return "六";
- }
- }