You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 08:36.

Get current Date and Time in Qt for Symbian

From Forum Nokia Wiki

Reviewer Approved   


ID ... Creation date June 11, 2009
Platform S60 3rd Edition, FP1, FP2
S60 5th Edition
Tested on devices Nokia 5800 XpressMusic
Category Qt for Symbian Subcategory


Keywords (APIs, classes, methods, functions): QDateTime::currentDateTime(), QDate::currentDate(), QTime::currentTime()

Overview

This code snippets shows how to get current date and time of device. API QDateTime::currentDateTime() will returns the current date and time, as reported by the system clock, in the local time zone. The QDate::currentDate() will return the current date , as reported by the system clock, in the local time zone. The QTime::currentTime() will return the current time , as reported by the system clock, in the local time zone.

This snippet can be self-signed. As it does not use any API which require developer/certified signing.

Preconditions

Headers required

#include <QDateTime>

Source

SystemTime::SystemTime(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
setWindowTitle("System Time");
ui.statusbar->showMessage("Showing system time");
 
//get current date
QDate date = QDate::currentDate();
QString dateString = date.toString();
ui.label->setText("Date: " + dateString);
 
//get current time
QTime time = QTime::currentTime();
QString timeString = time.toString();
ui.label_2->setText("Time: " + timeString);
 
//get current date and time
QDateTime dateTime = QDateTime::currentDateTime();
QString dateTimeString = dateTime.toString();
ui.label_3->setText("Date and Time: " + dateTimeString);
}


Postconditions

The code snippet is expected to show current date and time of device.

Image:SystemTime.JPG

External links

Code Example

  • The Code Example will show current date and time on screen and example is tested on Nokia 5800 XpressMusic.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fChangingE5fprofileE5fprogrammaticallyE5finE5fE51tX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ