js按指定格式显示日期时间的样式代码
2018-10-12 13:51
766 查看
时间为当前时间
//1.2013-4-9 11:21:32
//2.2013年4月9日 11点21分32秒
//3.2013年4月9日 上午11点21分32秒
//4.2013年4月9日 下午13点21分32秒
/*
var thedate = new Date();
alert(thedate.getFullYear() + '-' + thedate.getMonth() + '-' + thedate.getDate() + ' ' + thedate.toLocaleTimeString());
alert(thedate.toLocaleDateString() + ' ' + thedate.getHours() + '点' + thedate.getMinutes() + '分' + thedate.getSeconds() + '秒');
if (thedate.getHours() < 12) {
alert(thedate.toLocaleDateString() + ' 上午' + thedate.getHours() + '点' + thedate.getMinutes() + '分' + thedate.getSeconds() + '秒');
}
else {
alert(thedate.toLocaleDateString() + ' 下午' + thedate.getHours() + '点' + thedate.getMinutes() + '分' + thedate.getSeconds() + '秒');
}
*/
您可能感兴趣的文章:
相关文章推荐
- js按指定格式显示日期时间的样式代码
- js两行代码按指定格式输出日期时间
- js两行代码按指定格式输出日期时间
- 仅2行代码的javascript按指定格式显示日期时间效果
- 仅2行代码的javascript按指定格式显示日期时间效果
- [原创]两行代码解决javascript按指定格式显示日期时间
- js 毫秒数转换为指定格式日期的js代码
- 用js实现页面显示当前日期和时间的代码
- 计算2017年11月11日 11时 11分 11秒 距离当前日期的时间差, 并以指定的格式(天/时/分/秒)的形式显示.
- vue.js将时间戳转化为日期格式的实现代码
- js根据指定日期以周显示时间区间
- js动态显示当前日期,时间和星期代码
- JS显示当前日期和时间的代码(包括农历星期等)
- javascript两行代码按指定格式输出日期时间
- 用js实现页面显示当前日期和时间的代码
- JS实现网页标题栏显示当前时间和日期的完整代码
- 完整显示当前日期和时间的JS代码
- 界面显示这个时间格式的js代码: 2016年1月19日 星期二 乙未(羊)年 腊月初十
- javascript两行代码按指定格式输出日期时间
- js显示实时时间[样式:年/月/日 上下午 时:分:秒 星期几](仅需一行代码)