1.0.8 • Published 2 years ago

s94-inputdate v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

s94-inputdate

时间日期选择工具

安装

$ npm install s94-inputdate

使用

var inputdate = require('s94-inputdate');
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果,赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})

属性和方法

inputdate(callback[, fmt, initdate]) 调起时间日期控件界面

inputdate.init(config) 初始化,或者修改配置

callback函数接受的数据格式

fmt说明

inputdate(callback, fmt, initdate)

  • callback Function 接受时间日期选择的结果回调函数,接受一个对象,查看详细介绍
  • fmt String 返回的时间字符串格式样式,会根据fmt设定需要启用的控件,(默认值:Y-M-D H:I:S),查看详细介绍
  • initdate Date|String 初始化时间,为字符串格式需要和fmt一致,(默认值:new Date())
  • 返回 underfind

    调起时间日期控件界面

var inputdate = require('s94-inputdate');
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果,赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})

inputdate.init(config)

var inputdate = require('s94-inputdate');
inputdate.init({color: '#f00'});
$('input[type="text"]').on('click',function(){
	//调起插件界面
	var _this = this;
	inputdate(function(res){
		_this.value = res; //把选择的时间结果,赋值到input里面
	},'Y-M-D H:I:S', this.value); //已input的值作为初始数据
})

callback函数接受的数据格式

{
	value: "2022-01-25 20:25:33", //根据fmt格式化的时间字符串
	y: 2022, //年份的值{1970-}
	m: 1, //月份的值{1-12}
	d: 25, //当月第几天的值{1-31}
	h: 20, //小时的值{0-23}
	i: 25, //分钟的值{0-59}
	s: 33, //秒的值{0-59}
	Date: `Date`, //时间对象
}
//该对象可以直接当字符串使用,等效于value属性
inputdate(function(res){
	res.value == res; //true
	res.value === res; //false
}); //已input的值作为初始数据

fmt说明

返回的时间字符串格式样式。

字母ymdhis分别表示年月日时分秒,大写为有前置0、小写为没有前置0。

W为中文的星期几、w为星期序列(1为星期一... 7为星期天)

该参数和 s94.date(fmt, time) 中的fmt相同

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago