PDA

View Full Version : Qt.formatDate gives wrong output when device timezone is GMT-5:00.



sgm
1st December 2011, 06:07
I am using qt 4.7.3 to develop the app for S^3 devices.
In Qml I am converting date object to string using Qt.formatDate as shown below


property date shownDate: "2001-11-11"
shownDate = new Date(2011,4,1) //May 1, 2011
console.log(qt.formatDate(shownDate,"yyyy-MM-dd"))


Above code works fine if the timezone of the device is GMT-4:00 howerver when device time zone is changed to GMT-5:00,
the formated date printed in console is "2011-4-30" instead of printing "2011-5-1".

I am confused why the date is formatted wrongly.
Am I doing anything wrong in converting date to string and why this happens only for GMT-5:00 timezone?