Skip to Content

Sapui5 one before day problem

var sToday = new Date(); //today// example : 20.12.2017

this.getView().byId("mesaiTbdPicker").setDateValue(sToday); // set today to datepicker //20.12.2017

and I sending this data.But i looking data in abap date looking 1 before day. //19.12.2017

I tried this but not worked;

var sToday = new Date();

sToday = sToday + 1;

Please help.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Dec 21, 2017 at 10:19 PM

    You have to play with the timezone such as CET to get the correct date.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2017 at 02:15 PM

    Hi,

    Before sending date value to the oData you have to format it in format as "YYYY-MM-DDTHH:MM:SS". Use below formatter to do this. Passing date object to the odata cause this issue.

    // format date for create
    dateFormat:function(value) {
    	if(value == null){
    		return null;
    	}
        	var _smonth = value.getMonth() + 1;
    	var _sdate = value.getDate();
    	if (_smonth.toString().length < 2) {
    		_smonth = "0" + _smonth.toString();
    	}
    	if (_sdate.toString().length < 2) {
    		_sdate = "0" + _sdate.toString();
    	}
        	var	formatDate = value.getFullYear()	+ '-' + _smonth + '-' + _sdate + "T00:00:00";
    	return formatDate;
    },
    
    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2017 at 03:41 PM

    Hi,

    In addition to handling it on the front-end (to add on the point already made), you can add a day on the back-end ABAP side.

    Add comment
    10|10000 characters needed characters exceeded

    • I used abap code it elsewhere.So I can not change it there.But the problem is solved by itself.I didntunderstand. 2-3 hour after i checked code problem solved.
      
      Thanks for answer.
      
      
      
      
  • Dec 20, 2017 at 04:39 PM

    it may not be a problem, the browser is showing local time, the abap side is showing server time,

    Add comment
    10|10000 characters needed characters exceeded