JavaScript

超轻量级php框架startmvc

JS实现简单的星期格式转换功能示例

更新时间:2020-07-17 22:12:01 作者:startmvc
本文实例讲述了JS实现简单的星期格式转换功能。分享给大家供大家参考,具体如下:1.js代

本文实例讲述了JS实现简单的星期格式转换功能。分享给大家供大家参考,具体如下:

1. js代码


<script>
 //定义一个日期对象;
 var currentTime=new Date();
 //获得系统年份;
 var year=currentTime.getFullYear();
 //获得系统月份;
 var month=currentTime.getMonth();
 //获得系统当月分天数;
 var day=currentTime.getDate();
 //获得系统小时;
 var hours=currentTime.getHours();
 //获得系统分钟;
 var minutes=currentTime.getMinutes();
 //获得系统星期几;
 var dayCycle=currentTime.getDay();
 //使用数组更改日期样式;
 var dayCycleArray=["日","一","二","三","四","五","六"];
 for(var i=0;i<7;i++){
 if(dayCycle==i){
 //将dayCycleArray的数赋值到系统星期几里面中去;
 dayCycle=dayCycleArray[i];
 }
 }
 //打印完整的系统日期;
 document.write("<div class=\"div3\">"+year+"年"+month+"月"+day+"日"+hours+"时"+minutes+"分"+"星期"+dayCycle+"</div>");
</script>

2. 使用在线HTML/CSS/JavaScript代码运行工具:http://tools.jb51.net/code/HtmlJsRun,测试运行结果如下:

注:细心的读者应该注意到了,本文示例演示的结果中月份显示为上个月(6月份),这是因为getMonth()获取的月份是从0开始计算的,需要+1才可得到当前月份

PS:这里再为大家推荐几款时间及日期相关工具供大家参考使用:

在线日期/天数计算器: http://tools.jb51.net/jisuanqi/date_jisuanqi

在线日期计算器/相差天数计算器: http://tools.jb51.net/jisuanqi/datecalc

在线日期天数差计算器: http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix时间戳(timestamp)转换工具: http://tools.jb51.net/code/unixtime

JS 星期 格式转换
基础信息
请求
SQL查询
加载文件
配置
错误
总耗时: 89.97ms 内存: 88.71KB
请求方法: GET
请求URI: /article_35535.html
控制器: index
方法: index
PHP版本: 8.0.26
服务器: nginx/1.24.0
GET参数
无GET参数
POST参数
无POST参数
请求头
Cookie: PHPSESSID=ak5mn1qsj453sgf8uifvnt0998
Accept-Encoding: gzip, br, zstd, deflate
User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Accept: */*
Host: startmvc.com
Content-Length:
Content-Type:
Cookie
PHPSESSID: ak5mn1qsj453sgf8uifvnt0998
SELECT id,name FROM sm_article_category 0.00ms
SELECT a.id,a.category_id,a.title,a.keywords,a.description,a.update_time,ac.content FROM sm_article as a JOIN sm_article_content as ac ON ac.article_id = a.id WHERE a.id = '35535' LIMIT 1 0.00ms
SELECT tag_id FROM sm_tag_article WHERE article_id = '35535' 0.03ms
select id,title from sm_article where id in (select article_id from sm_tag_article where tag_id=34226) and status=1 order by id desc limit 20 0.00ms
总计:4 条SQL语句 总耗时:0.03 ms
1. /www/wwwroot/startmvc.com/public/index.php
2. /www/wwwroot/startmvc.com/startmvc/boot.php
3. /www/wwwroot/startmvc.com/startmvc/function.php
4. /www/wwwroot/startmvc.com/vendor/autoload.php
5. /www/wwwroot/startmvc.com/vendor/composer/autoload_real.php
6. /www/wwwroot/startmvc.com/vendor/composer/platform_check.php
7. /www/wwwroot/startmvc.com/vendor/composer/ClassLoader.php
8. /www/wwwroot/startmvc.com/vendor/composer/autoload_static.php
9. /www/wwwroot/startmvc.com/startmvc/core/Config.php
10. /www/wwwroot/startmvc.com/config/common.php
11. /www/wwwroot/startmvc.com/startmvc/core/Session.php
12. /www/wwwroot/startmvc.com/startmvc/core/App.php
13. /www/wwwroot/startmvc.com/startmvc/core/Exception.php
14. /www/wwwroot/startmvc.com/function/custom_function.php
15. /www/wwwroot/startmvc.com/function/global_function.php
16. /www/wwwroot/startmvc.com/startmvc/core/Request.php
17. /www/wwwroot/startmvc.com/startmvc/core/Middleware.php
18. /www/wwwroot/startmvc.com/startmvc/core/Router.php
19. /www/wwwroot/startmvc.com/config/route.php
20. /www/wwwroot/startmvc.com/app/home/controller/ArticleController.php
21. /www/wwwroot/startmvc.com/app/common/BaseController.php
22. /www/wwwroot/startmvc.com/startmvc/core/Controller.php
23. /www/wwwroot/startmvc.com/startmvc/core/Loader.php
24. /www/wwwroot/startmvc.com/startmvc/core/View.php
25. /www/wwwroot/startmvc.com/config/view.php
26. /www/wwwroot/startmvc.com/startmvc/core/Db.php
27. /www/wwwroot/startmvc.com/config/database.php
28. /www/wwwroot/startmvc.com/startmvc/core/db/DbCore.php
29. /www/wwwroot/startmvc.com/startmvc/core/db/DbInterface.php
30. /www/wwwroot/startmvc.com/runtime/temp/home/article/detail.php
31. /www/wwwroot/startmvc.com/startmvc/core/tpl/trace.php
总计:31 个文件
系统配置
运行环境: development
调试模式: 开启
时区设置: Asia/Shanghai
最大执行时间: 300秒
内存限制: 128M
上传限制: 50M
POST限制: 50M
字符集: UTF-8
错误报告级别: 32759
缓存状态
APC: 不可用
Memcached: 不可用
Redis: 不可用
OPcache: 可用
XCache: 不可用
File Cache: 可用
Autoload: 1 个加载器
Session: 已激活
框架配置
session: [Array]
trace: 1
debug: 1
default_controller: Index
default_action: index
异常信息
未捕获到异常
错误信息
未发现错误
应用运行正常,未发现错误或异常
89.97ms