问题在于你的时间是什么对象存放的,如果是时间object则直接就可以通过getFullYear()等方法取出,如果是字符串,则需要用subStr等函数截取组装

解决方案 »

  1.   

    var _todayDate = new Date();
    var t_year = this._todayDate.getFullYear();
    var t_month = this._todayDate.getMonth()+1;
    var t_date = this._todayDate.getDate();
    var t_hour = this._todayDate.getHours();
    var t_minute  = this._todayDate.getMinutes();
    var t_sec  = this._todayDate.getSeconds();然后把年月日时分秒,用字符串连接起来变成2006-11-27 16:15的格式
      

  2.   

    发的时候太出现了,前面的代码多了this,下面的是对的
    var _todayDate = new Date();
    var t_year = _todayDate.getFullYear();
    var t_month = _todayDate.getMonth()+1;
    var t_date = _todayDate.getDate();
    var t_hour = _todayDate.getHours();
    var t_minute  = _todayDate.getMinutes();
    var t_sec  = _todayDate.getSeconds();