php对字符串的操作4之 字符串的格式化函数

strtolower($str )

strtoupper($str )

大小写转换

strtotime('2018-1-1 0:0')

字符串转时间戳

date('Y-m-d H:i:s',time())

格式化时间戳

<?php
//大小写转换
$str = 'WWW.BAIDU.COM';
echo $str = strtolower($str ),'<hr>';
echo $str = strtoupper($str ),'<hr>';

//字符串转时间戳
date_default_timezone_set('PRC'); //设置默认时区
echo $chuo = strtotime('2018-1-1 0:0'),'<hr>';
//格式化时间戳
echo date('Y-m-d H:i:s',$chuo),'<hr>';
echo date('Y-m-d H:i:s',time()),'<hr>';

//千位分隔符函数
$num = 123456789.125;
echo number_format($num,2),'<hr>';

//加密
echo md5(md5(123456)),'<hr>';
echo sha1(123456);
?>

猜你喜欢

转载自www.cnblogs.com/cl94/p/9015773.html