Network Date and Time Tutorial

This tutorial describes how to retrieve the date and the time from the network.

  1. To get the network date and time settings, use RMobilePhone::GetNITZInfo(). This returns a RMobilePhone::TMobilePhoneNITZ object, derived from TDateTime. The iNitzFieldsUsed member, of type RMobilePhone::TMobilePhoneNITZCaps, describes what fields are available.
  2. To get the notification of any changes to the type of time information available, use RMobilePhone::NotifyNITZInfoChange().

Date and time example

The following code checks if time information is available, and if so, stores the day information in the variable day.

The code assumes iMobilePhone is an RMobilePhone object.

RMobilePhone::TMobilePhoneNITZ NITZInfo;
User::LeaveIfError(iMobilePhone.GetNITZInfo(NITZInfo));
TInt day = -1;

if (NITZInfo.iNitzFieldsUsed & RMobilePhone::KCapsTimeAvailable)
    {
     day = NITZInfo.Day();
    }