zoukankan      html  css  js  c++  java
  • JavaScript(jQuery)实现打印英文格式日期

    工作中遇到的功能点,觉得以后可以复用,就打算备一下咯

    格式要求(例):On Friday, July 14, 2017

    我的思路是用js就可以实现了,具体代码如下:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>index</title>
      </head>
      <body>
        <h1>Hello, world!</h1>
        <p class="current-time"></p>
    
        <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
    
        <script type="text/javascript">
        $(function() {
          //全局对象
          //当前时间
          var curTime=new Date()
    
          //枚举周天
          var weekday=new Array(7);
          weekday[0]="Sunday";
          weekday[1]="Monday";
          weekday[2]="Tuesday";
          weekday[3]="Wednesday";
          weekday[4]="Thursday";
          weekday[5]="Friday";
          weekday[6]="Saturday";
    
          //枚举月份
          var month=new Array(12);
          month[0]="January";
          month[1]="February";
          month[2]="March";
          month[3]="April";
          month[4]="May";
          month[5]="June";
          month[6]="July";
          month[7]="August";
          month[8]="September";
          month[9]="October";
          month[10]="November";
          month[11]="December";
    
          //当前日期信息
          var strCurTime = "On " + weekday[curTime.getDay()] +", "+month[curTime.getMonth()] + " " + curTime.getDate() + ", " + curTime.getFullYear();
          $(".current-time").html(strCurTime);
        });
        </script>
      </body>
    </html>
  • 相关阅读:
    网络编程最佳实践一
    【NYOJ】[599]奋斗的小蜗牛
    【NYOJ】[599]奋斗的小蜗牛
    【NYOJ】[477]A+B Problem III
    【NYOJ】[477]A+B Problem III
    【NYOJ】[811]变态最大值
    【NYOJ】[811]变态最大值
    【POJ】[1417]True Liars
    【POJ】[1417]True Liars
    【杭电】[3038]How Many Answers Are Wrong
  • 原文地址:https://www.cnblogs.com/hsiaochinchin/p/14013256.html
Copyright © 2011-2022 走看看