Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10
Accepted Solution

QDateTime in qml?



Just wondering how do you import and use the QDateTime object in qml?



Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: QDateTime in qml?

together with a DatePicker ?

ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: QDateTime in qml?

any reason you need QDateTime?


why not use the javascript date object?

var date = new Date();

var formattedDate = Qt.formatDateTime(date,"yyyyMMdd"); //to format date


you can't store a javascript date object in a 'propery variant' qml but you could simply import a javascript with a variable to persist this data within a QML context.

Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: QDateTime in qml?

I was curious on how to import it. Javascript date object works, as well.

For anyone who need to use this in the future with DateTimePicker, you can use the Date.toISOString() function.