JS Calendar API
JS Calendar API
js 如何获取当天是周几(一周的第几天)
const date = new Date();
// Mon Mar 23 2020 15:15:36 GMT+0800 (China Standard Time)
date.getFullYear();
// 2020
date.getDay();
// 1
date.getDate();
// 23
getWeekDay
const log = console.log;
const week = ["日", "一", "二", "三", "四", "五", "六"];
const day = new Date().getDay();
const weekday = week[day];
log(`今天是星期`, weekday);
const log = console.log;
const week = ["日", "一", "二", "三", "四", "五", "六"];
const day = new Date().getDay();
const weekday = week.charAt(day);
log(`今天是星期`, weekday);
// 判断时间是凌晨,早上,上午,中午,下午,傍晚,晚上,深夜
const log = console.log;
const now = new Date();
const hour = now.getHours();
if(hour < 6){
log("凌晨")
} else if (hour < 9){
log("早上")
} else if (hour < 12){
log("上午")
} else if (hour < 14){
log("中午")
} else if (hour < 17){
log("下午")
} else if (hour < 19){
log("傍晚")
} else if (hour < 22){
log("晚上")
} else {
log("深夜")
}
// 判断时间是上午,下午
if(hour <= 12){
log("上午")
}else{
log("下午")
}
Google Calendar API
https://developers.google.com/calendar/quickstart/js
https://developers.google.com/calendar/quickstart/nodejs
padStart
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart

const date = new Date()
const dateString = date.toLocaleString();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
`${month + '.' + day}`
// "4.8"
`${month}`.padStart(2, "0") + '.' + `${day}`.padStart(2, "0");
// "04.08"
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
JS Calendar API的更多相关文章
- 原生JS实战:写了个一边玩游戏,一边记JS的API的游戏
本文是苏福的原创文章,转载请注明出处:苏福CNblog:http://www.cnblogs.com/susufufu/p/5878913.html 本程序[一边玩游戏,一边记JS的API]是本人的个 ...
- [转载]fullPage.js中文api 配置参数~
fullPage.js中文api 配置参数 选项 类型 默认值 说明 verticalCentered 字符串 true 内容是否垂直居中 resize 布尔值 false 字体是否随着窗口缩放而缩放 ...
- AngularJS 授权 + Node.js REST api
作者好屌啊,我不懂的他全都懂. Authentication with AngularJS and a Node.js REST api 几个月前,我开始觉得 AngularJS 好像好牛逼的样子,于 ...
- Node.js RESTful API
什么是REST架构? REST表示代表性状态传输.REST是一种基于Web标准的架构,并使用HTTP协议. 它都是围绕着资源,其中每一个组件是资源和一个资源是由一个共同的接口使用HTTP的标准方法获得 ...
- Asp.net MVC集成Google Calendar API(附Demo源码)
Asp.net MVC集成Google Calendar API(附Demo源码) Google Calendar是非常方便的日程管理应用,很多人都非常熟悉.Google的应用在国内不稳定,但是在国外 ...
- Practical Node.js (2018版) 第8章:Building Node.js REST API Servers
Building Node.js REST API Servers with Express.js and Hapi Modern-day web developers use an architec ...
- jQuery-全屏滚动插件【fullPage.js】API 使用方法总结
jQuery-全屏滚动插件[fullPage.js]API 使用方法总结 jQuery-全屏滚动插件fullPage.js使用方法总结 作者github及下载地址:https://github.c ...
- Node.js 常用 API
Node.js v6.11.2 Documentation(官方文档) Buffer Prior to the introduction of TypedArray in ECMAScript 20 ...
- 十个书写Node.js REST API的最佳实践(上)
收录待用,修改转载已取得腾讯云授权 原文:10 Best Practices for Writing Node.js REST APIs 我们会通过本文介绍下书写Node.js REST API的最佳 ...
随机推荐
- 类型检查和鸭子类型 Duck typing in computer programming is an application of the duck test 鸭子测试 鸭子类型 指示编译器将类的类型检查安排在运行时而不是编译时 type checking can be specified to occur at run time rather than compile time.
Go所提供的面向对象功能十分简洁,但却兼具了类型检查和鸭子类型两者的有点,这是何等优秀的设计啊! Duck typing in computer programming is an applicati ...
- FridaHook框架学习(1)
FridaHook框架学习(1) 前言 本次学习过程参考https://bbs.pediy.com/thread-227232.htm Frida安装与使用 Windows端安装 pip instal ...
- equals()方法和hashCode()方法
1.equal()方法 2.hasCode()方法 2.1 Object的hashCode() 2.2 hashCode()的作用 3.String中equals()和hashCode()的实现 4. ...
- 编程排序的一个excel-据说玩的好的,年薪50万了。只是你没在对的地方
是一个excel 下面是百度网盘分享地址; http://pan.baidu.com/s/1kTwqRfL
- HTML字体
字体相关的样式 color 用来设置字体颜色 font-size 字体的大小 和font-size相关的单位 em 相当于当前元素的一个font-size rem 相当于根元素的一个font-size ...
- UI的管理
游戏的UI系统往往会比较复杂,工作量比较庞大,需要多人协作完成,为了开发和维护方便,有必要对UI系统进行管理. 一.制作预制件 将UI的各个不同的功能面板制作为预制件,放入Resources目录下,方 ...
- docker(11)Dockerfile 中的COPY与ADD 命令
前言 Dockerfile 中提供了两个非常相似的命令 COPY 和 ADD,本文尝试解释这两个命令的基本功能,以及其异同点,然后总结其各自适合的应用场景. Build 上下文的概念 在使用 dock ...
- Pytest(2)使用和调用方法
Pytest执行用例规则 Pytest在命令行中支持多种方式来运行和选择测试用例 1.对某个目录下所有的用例 pytest 2.对模块中进行测试 pytest test_mod.py 3.对文件夹进行 ...
- git从安装到多账户操作一套搞定(一)入门使用
作者:良知犹存 转载授权以及围观:欢迎添加微信:Allen-Iverson-me-LYN 总述 GIT是当今热门代码管理技术,但是如此火的系统,竟然是大神林纳斯花了两周用C写出来的一个分布式版 ...
- Windows10与虚拟机中CentOS-7.2进行telnet通信 出现在端口23处失败【解决】
(telnet服务是由xinetd守护,所以安装和启动都要用到xinetd) 1.先检查CentOS7.0是否已经安装以下几个安装包:telnet-server.telnet.xinetd.命令如下: ...