当前位置:网站首页>学习使用php将时间戳转换为大写日期的方法代码示例
学习使用php将时间戳转换为大写日期的方法代码示例
2022-07-02 11:56:00 【徊忆羽菲】
效果图
当前日期小写-----2022-06-27 17:45:25
当前日期大写----- 二〇二二年六月二十七日
当前日期大写-----贰零贰贰年陆月贰拾柒日
封装方法
function dateTimeToUpper($stamp, $type)
{
$year = str_split(date('Y', $stamp));
$month = intval(date('m', $stamp));
$day = intval(date('d', $stamp));
$chars = array(
0 => ['〇', '零'],
1 => ['一', '壹'],
2 => ['二', '贰'],
3 => ['三', '叁'],
4 => ['四', '肆'],
5 => ['五', '伍'],
6 => ['六', '陆'],
7 => ['七', '柒'],
8 => ['八', '捌'],
9 => ['九', '玖'],
10 => ['十', '拾'],
11 => ['十一', '拾壹'],
12 => ['十二', '拾贰'],
13 => ['十三', '拾叁'],
14 => ['十四', '拾肆'],
15 => ['十五', '拾伍'],
16 => ['十六', '拾陆'],
17 => ['十七', '拾柒'],
18 => ['十八', '拾捌'],
19 => ['十九', '拾玖'],
20 => ['二十', '贰拾'],
21 => ['二十一', '贰拾壹'],
22 => ['二十二', '贰拾贰'],
23 => ['二十三', '贰拾叁'],
24 => ['二十四', '贰拾肆'],
25 => ['二十五', '贰拾伍'],
26 => ['二十六', '贰拾陆'],
27 => ['二十七', '贰拾柒'],
28 => ['二十八', '贰拾捌'],
29 => ['二十九', '贰拾玖'],
30 => ['三十', '叁拾'],
31 => ['三十一', '叁拾壹'],
);
$date = '';
foreach ($year as $y) {
$date .= $chars[$y][$type];
}
$date .= '年';
$date .= $chars[$month][$type] . '月';
$date .= $chars[$day][$type] . '日';
return $date;
}
echo '当前日期小写==' . $now_time = date('Y-m-d H:i:s', time());
echo '<br>';
echo '当前日期大写=第一种样式=' . dateTimeToUpper(time(), 0);
echo '<br>';
echo '当前日期大写=第二种样式=' . dateTimeToUpper(time(), 1);
echo '<br>';
边栏推荐
- 数据库内容输出有问题怎么解决
- C#代码审计实战+前置知识
- Key points of compilation principle examination in 2021-2022 academic year [overseas Chinese University]
- 1. Editing weapon VIM
- Edit the formula with MathType, and set it to include only mathjax syntax when copying and pasting
- Yolov6 training: various problems encountered in training your dataset
- 关于网页中的文本选择以及统计选中文本长度
- STM32 standard firmware library function name memory (II)
- C language exercises - (array)
- 广州市应急管理局发布7月高温高湿化工安全提醒
猜你喜欢
蜻蜓低代码安全工具平台开发之路
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
[noi simulation] Elis (greedy, simulation)
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
obsidian安装第三方插件——无法加载插件
forEach的错误用法,你都学废了吗
富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
Wechat applet uses towxml to display formula
About text selection in web pages and counting the length of selected text
Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
随机推荐
Reuse and distribution
MFC CString 转 char*
Fundamentals of software testing
About text selection in web pages and counting the length of selected text
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
Printf function and scanf function in C language
info [email protected] : The platform “win32“ is incompatible with this module.
Edit the formula with MathType, and set it to include only mathjax syntax when copying and pasting
为什么只会编程的程序员无法成为优秀的开发者?
【apipost】使用教程
2. Const pointer
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
C thread transfer parameters
jmeter脚本参数化
. Net core logging system
Find the maximum inscribed circle of the contour
C#延时、在线程中开启定时器、获取系统时间
Have you learned the wrong usage of foreach
[noi simulation] Elis (greedy, simulation)
解决el-radio-group 回显后不能编辑问题