摘要:本篇教程介绍了jQuery如何实现打印英文格式日期,希望阅读本篇文章以后大家有所收获,帮助大家对jQuery的理解更加深入。
本篇教程介绍了jQuery如何实现打印英文格式日期,希望阅读本篇文章以后大家有所收获,帮助大家对jQuery的理解更加深入。
<
格式要求(例):On Friday, July 14, 2017
我的思路是用js就可以实现了,具体代码如下:
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8 <title>index</title>
9 </head>
10 <body>
11 <h1>Hello, world!</h1>
12 <p class="current-time"></p>
13
14 <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
15
16 <script type="text/javascript">
17 $(function() {
18 //全局对象
19 //当前时间
20 var curTime=new Date()
21
22 //枚举周天
23 var weekday=new Array(7);
24 weekday[0]="Sunday";
25 weekday[1]="Monday";
26 weekday[2]="Tuesday";
27 weekday[3]="Wednesday";
28 weekday[4]="Thursday";
29 weekday[5]="Friday";
30 weekday[6]="Saturday";
31
32 //枚举月份
33 var month=new Array(12);
34 month[0]="January";
35 month[1]="February";
36 month[2]="March";
37 month[3]="April";
38 month[4]="May";
39 month[5]="June";
40 month[6]="July";
41 month[7]="August";
42 month[8]="September";
43 month[9]="October";
44 month[10]="November";
45 month[11]="December";
46
47 //当前日期信息
48 var strCurTime = "On " + weekday[curTime.getDay()] +", "+month[curTime.getMonth()] + " " + curTime.getDate() + ", " + curTime.getFullYear();
49 $(".current-time").html(strCurTime);
50 });
51 </script>
52 </body>
53 </html>
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标WEB前端jQuery频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号