wrong date on ipod touch

You must Login before you can answer or comment on any questions.

var value =  new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
var yr1 = value.getFullYear();
var mon1 = value.getMonth() + 1;
var day1 = value.getDate();
var dvalue = mon1 + '/' + day1 + '/' + yr1 + ' ' + '4:00 PM';
 
var tf1 = Titanium.UI.createTextField({
    height : 40,
    hintText : 'Select Date',
    width : 300,
    left : 0,
    top : 10,
    color : '#000000',
    value : dvalue,
    borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
gives me 1/1/1970 4:00 PM as the date on my ipod touch.

What am I doing wrong?

— asked 8 months ago by Weina Scott
3 Comments
  • What does it give you if you just do a new Date()??

    — commented 8 months ago by Anthony Decena

  • you might want to show some love to the people who helped you out in your previous question?

    http://developer.appcelerator.com/question/142892/how-to-add-a-date

    — commented 8 months ago by Aaron Saunders

  • var d = new Date();

    var day = d.getDate();

    var month = d.getMonth() + 1;

    var year = d.getFullYear();

    var toDay= month+ '/'+ day+'/'+year;

    Ti.API.info('toDay is '+ toDay);

    gives me ToDay is 10/1/2012

    var value = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);

    var yr1 = value.getFullYear();

    var mon1 = value.getMonth()+1;

    var day1 = value.getDate();

    var time= value.getTime();

    var dvalue = mon1 + '/' + day1 + '/' + yr1 + ' ' + '4:00 PM';

    gives me Date Value is 10/2/2012 4:00 P

    — commented 8 months ago by Muhammad Adnan

1 Answer

Accepted Answer

Your code should work, try a clean build. 1/1/1970 corresponds to a date value of 0. So either your date is set wrong, or you have skipped some lines of code that set value=0.

Your Answer

Think you can help? Login to answer this question!