Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Steps to reproduce the problem
- Set the timezone of the device as Brasilia, Brazil(GMT+3).
- Pick a date from date picker dialog as 20th March 2012.
- JScript's Date() will display 19th March 2012, whereas QDateTime will fetch 20th March 2012.
import QtQuick 1.0
import com.nokia.extras 1.0
property string dateStr;
// 'date' could be used to display actual date picked from dialog
// Following code snippet does not take DST into account.
// The snippet will give wrong Date/Time value where DST is maintained
// For DST, set “dateStr” date and time values to JS Date in the below code.
var dt=new Date();
dt.setDate(tDialog.day);//dateDialog default starts on 1
jsdt.text= "JS Date: "+Qt.formatDateTime(dt, Qt.DefaultLocaleShortDate );
tMainView::tMainView(QWidget *parent) :
QWidget* pWidget = new QWidget();
DecView = new QDeclarativeView(pWidget);
DecView->rootContext()->setContextProperty("tMainView", this );
QString tMainView::getDate(int y, int m,int d)
QDateTime now = QDateTime::currentDateTime();
QString str("Date: "+date.toString()+" "+nowTime.toString());