1. html代码:

<input id="txtBeginTime" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser"></input> <b>--</b>
<input id="txtEndTime" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser"></input>

2. js代码:

    function myformatter(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
} function myparser(s){
if (!s) return new Date();
var ss = (s.split('-'));
var y = parseInt(ss[0],10);
var m = parseInt(ss[1],10);
var d = parseInt(ss[2],10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
return new Date(y,m-1,d);
} else {
return new Date();
}
} //页面加载    $(function(){ //设置时间
     var curr_time = new Date();
    $("#txtBeginTime").datebox("setValue",myformatter(curr_time));
    $("#txtEndTime").datebox("setValue",myformatter(curr_time));
    //获取时间
    var beginTime=$("#txtBeginTime").datebox("getValue");
    var endTime=$("#txtEndTime").datebox("getValue"); });

来源:https://www.cnblogs.com/ry123/p/3831824.html

datebox设置默认时间的更多相关文章

  1. 安装xampp无法设置默认时间的坑

    xampp无法设置默认时间,修改了时间还是无效 [Date] ; Defines the default timezone used by the date functions ; http://ph ...

  2. Sqlite 设置默认时间为本地时间

    Sqlite 设置默认时间为本地时间 先设置字段类型为datetime, 再把缺省值设置为datetime( 'now', 'localtime' ) 代码查看如下 Time DATETIME DEF ...

  3. Mysql中设置默认时间为系统当前时间

    Mysql中设置默认时间为系统当前时间 数据库设计时会遇到的一种情况:将系统当前时间设成默认值存储 数据库设计编码: CREATE TABLE `test` ( `name` varchar(50) ...

  4. [前端_EasyUI]给easyui的datebox设置默认值,获取不到 的解决方法

    //给eayui datebox设置初始值 $("#ctime").datebox("setValue", function(){ var date = new ...

  5. EasyUI--datebox设置默认时间

    1. html代码: <input id="txtBeginTime" class="easyui-datebox" data-options=" ...

  6. Mysql中设置默认时间为当前值

    1.直接在创建表时添加该列并声明默认值,如下: CREATE TABLE `table1` ( `id` ) NOT NULL, `createtime` timestamp NULL default ...

  7. mysql中TIMESTAMP设置默认时间为当前时间

    在我们保存数据进入到数据库中时多半会使用像php之类的脚本来获取一个时间保存到mysql中,其实在mysql可以直接使用TIMESTAMP 数据类型来实现默认类型了,下面一起来看看.   很多时候,为 ...

  8. mysql 设置默认时间为now()

    TIMESTAMP的变体1,TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP在创建新记录和修改现有记录的时候都对这个数据列 ...

  9. 【MySQL】函数IFNULL、设置默认时间

    MySql 函数 IFNUll用法说明 IFNULL(expr1,expr2) 如果 expr1 不是 NULL,IFNULL() 返回 expr1,否则它返回 expr2. IFNULL()返回一个 ...

随机推荐

  1. 将你的数据导入到json格式

    不知道为什么大家那么偏爱json格式,清晰?跨平台?或许这都是它的优点吧,之前我都是将我的数据放到txt中,今后就用json吧.初步写了一个写入json的模板,就这么用吧. def get_qq_05 ...

  2. electron实现MessageBox

    1.在渲染进程引用主进程模块 var remote = require('electron').remote; var dialog = remote.dialog; 2.实现一点简单的确定取消操作 ...

  3. 阿里云 安装docker

    转  https://www.jianshu.com/p/f02d63ee98e0

  4. DataTable Distinct

    DataView dataView = dtTemp.DefaultView; DataTable dataTableDistinct = dataView.ToTable(true, "U ...

  5. java-工厂

    class Mouse{ public void sayHi(){}; } class DellMouse extends Mouse { @Override public void sayHi() ...

  6. C++函数形参与实参交换

    c++中函数的实参传递到形参的值是单向的,改变形参并不会影响实参. #include <iostream> using namespace std; void swap(int a, in ...

  7. 文件和异常的练习3——python编程从入门到实践

    10-10 常见单词:访问项目Gutenberg(http://gutenberg.org/),并找一些你想分析的图书.下载这些作品的文本文件或将浏览器中的原始文本复制到文本文件中. 可以使用coun ...

  8. PB 选择继承父类的注意事项

    1.父类的datewindow 的祖先类最好不是n_dw_single ,最好是n_dw_grid,n_dw_single  的标题行没有阴影.排序,没有行聚焦等功能(非常初始的).n_dw_grid ...

  9. MEF在WCF REST中实际应用2(Global.asax注册)

    IOCContainer文件: public class IOCContainer { /// <summary> /// 容器 /// </summary> public s ...

  10. c# js 时间

    DateTime GetTime(double timeStamp) { DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new Dat ...