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的最佳 ...
随机推荐
- Go is more about software engineering than programming language research.
https://talks.golang.org/2012/splash.article Go at Google: Language Design in the Service of Softwar ...
- 初始TypeScript
什么是TypeScript? TypeScript是拥有类型系统的JavaScript的超集,可以编译成纯JavaScript: 1.类型检查:TS会在编译代码时进行严格的静态类型检查,这意味着可以在 ...
- Spring Boot的进阶和高级
一.Repository接口 二.Repository子接口 三.@Query注解 四.更新及删除操作整合事物 五.CrudRepository接口 六.PagingAndSortingReposit ...
- java-poi创建模板
package com.jy.demo.web; import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.Cell; i ...
- dedecms文章页的上下篇颠倒的问题
dedecms的文章页底下的上下篇,如果按照时间排序的话,最新的一篇应该是最上了,但是底下还是会显示上一篇文章还有,然后下一篇文章没有了,就是颠倒了.如何修改呢. 1.修改include目录下arc. ...
- jqXHR.fail()回调方法及其参数详细说明
jqXHR.fail()是一个可供选择的 error 回调选项的构造函数,.fail()方法取代了的过时的.error()方法.从 jQuery 1.5 开始,$.ajax()返回的jqXHR对象 实 ...
- 痞子衡嵌入式:恩智浦MCUX SDK在GitHub上线了
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家讲的是恩智浦MCUX SDK 在GitHub上线一事. 其实在差不多一个月前(2021年1月6日),恩智浦MCUX SDK就在GitHub悄悄上 ...
- Malaysia Trip Memory ('-ωก)
独白 初次见面,睡意阑珊.日轮.稀疏.惨白色.墨绿色,\(\rho_{atm}>\rho_{space}\) 的作用被赤道所隐藏,一时的不知所从,斑斓成了单一.之后的故事,踏上一辆盛装打扮的 ...
- 使用networkx库可视化对称矩阵的网络图形
首先我的数据是.mat格式,讲讲如何用python读取.mat格式的数据(全套来) 我是python3版本 第一种读取方法: import h5py features_struct = h5py.Fi ...
- Django服务器布置(Ubuntu+uwsgi+nginx+Django)
一.安装Python apt install python3 二.安装pip apt install python3-pip 三.创建目录 创建虚拟服务目录 mkdir -p /data/env 创建 ...