# What AT command should be sent to modem to get time?

I am using SIM800E. I want to know what AT command should be sent to the modem to get time? This modem has a RTC. But I need to set it automatically through cell tower. The tower can send the time to the modem when requested using an AT command. I have seen in many phones that the time is updated during hand-offs.

The manual does not have this information.

• According to that hardware design document you need to obtain the "SIM800E AT Command Manual" - a separate document. – RedGrittyBrick Sep 12 '13 at 7:24
• Then in practice how simple non-Multimedia phones update location? – gpuguy Sep 12 '13 at 8:27
• NITZ is an optional part of the GSM standards, not supported by all carriers and may not be accurate to better than a few minutes. – RedGrittyBrick Sep 12 '13 at 8:43
• I believe this is on topic because it concerns the use of an embedded GSM module for M2M communications. Why is this post off-topic, and the four posts following were allowed: example 1 2 3 4 – tcrosley Sep 12 '13 at 20:23

I have used the following command:

AT+CCLK?


which returns the date and time, like:

+CCLK: "00/01/12,05:44:53+00"


successfully in products using three different cell modules: Enfora, Telit, and Sierra. The fact that it uses a + character after the AT implies it is a common (as opposed to proprietary) command, and should be available on most if not all cell modules. (Proprietary commands use a vendor specific character after the AT, like AT$, AT%, AT! etc.) As I mentioned in a comment, if you can't get the time using this command (for example, it returns all 0's), then another way is to connect to the network and get the time off of a server using an HTTP command. For example, the following HTTP request: HEAD /index.html HTTP/1.1\r\n Host: www.somehost.com\r\n; \r\n  where somehost is either your own server or Google.com etc. This also assumes index.html is the main page for the site (not the case for Google). It will return a header like: HTTP/1.x 200 OK Transfer-Encoding: (something) Date: Fri, 13 Nov 2013 04:36:25 GMT (lots more stuff)  As far as I know, all severs are obligated to return GMT time in their headers. • Some stuff I read suggested the value returned by +CCLK may be from the on-board clock (RTC), not from the GSM network (tower). – RedGrittyBrick Sep 13 '13 at 21:04 • I have read the command described that way also, however I have been using it in several different products using three different cell modules over the last five years or so, and it has worked just about everywhere in the US and also Europe and Asia. There has been a few carriers, for example one in Germany, where it didn't work (returned all 0's); I contacted them and were told they didn't support time updates over the network. So I wrote code to do an HTTP 1.1 request and grab the time off of a server. – tcrosley Sep 13 '13 at 21:51 • I think the HTTP request could be better written as HEAD / HTTP/1.0\r\nHost: example.com\r\n\r\n as I feel / is less prone to 404s and that HTTP 1.0 better represents our (device-wise) ignorance of HTTP. Besides, the semicolon looks like a typo. Other than that, the date is GMT/UTC by specification (see also). – Tibo Aug 18 '15 at 11:26 • This answer is informing but deserves an update regarding the onboard RTC vs. network time problem. – Tibo Aug 18 '15 at 11:30 First of all, NITZ is poorly supported in many networks (can you say COST-CUTTING). I would not rely on it at all as 1 in 10 networks use it, especially in far flung places. Secondly +CCLK command is for the internal RTC of the modem. Some modems have facilities to update this clock from the network. Relying on this is risky. The above HTTP request is incomplete i.e. it doesn't work. I used to know how to do this so will revert back when it works. The fact that it uses a + character after the AT implies it is a common (as opposed to proprietary) command, and should be available on most if not all cell modules. (Proprietary commands use a vendor specific character after the AT, like AT$, AT%, AT! etc.)

This is not entirely true. There are proprietary modem commands that follow the AT+ convention. For example AT+WOPEN is a proprietary Sierra command.

There are a certain set of commands that are the same regardless of modem. These are defined in the 3GPP documents. The proprietary commands are usually defined in the vendor's user manuals and clearly marked as being proprietary.

AT+CLTS=1 ( Get local time stamp ) AT&W ( Save configuration )

Turn off modem and turn on modem(reboot to get local time from network)

Next time when modem boots up you should be able to get local time by network and can be read by sending

AT+CCLK?

This worked for me i m using SIM800 GSM modem read AT command descriptions for more information

PuTTY:

AT+COPS=2

OK

AT+CTZU=1

OK

AT+COPS=0

OK

+CTZU: "15/05/06,17:25:42",-12,0


Works perfectly, after that you have to parse the result and place in clk because this does not happen automatically. (at least in my Cinterion)

• It would help if you could explain, in English, what this does and why it is a solution to the question. – David May 6 '15 at 18:25
• @David Stay tuned, we are working on a translation in the chat. – Nick Alexeev May 6 '15 at 19:37
• Variant for SIM800H that worked for me: use AT+CLTS=1 instead of AT+CTZU=1 (since CTZU isn't supported). Then you'll get an unsolicited message like *PSUTTZ: 2017,1,30,20,17,28,"-20",0 when you reregister – Matt Thomas Jan 30 '17 at 20:21

NITZ as pointed out by RedGrittyBrick is the answer. However, this is a message that's sent by the network only, usually on joining the network. Some carriers send it, some don't. There's no standard way to request it.

Here is the AT command sequence to get the cellular network time.It worked in my UBLOX LEON G-200 GSM module.

GSM_Send_Modem_Command("AT+COPS=2\r\n");//de register
GSM_Send_Modem_Command("AT+CTZU=1\r\n");//automatic time zone update is enabled
GSM_Send_Modem_Command("AT+COPS=0\r\n");// register to network
GSM_Send_Modem_Command("AT+CCLK?\r\n");// gets the clock of the MT


first send this two command
AT+CLTS=1;&W

AT+CFUN=1,1 and than AT+CLTS? check whether you get this reply +clts: 1
and than send this command AT+CCLK?

• Welcome to EE.SE. Use two back-ticks () around code snippets in your posts or use the {} button on the editor toolbar for blocks of code as in the other answers. This will give a grey background and fixed width font making it easy to see where your code starts and ends. – Transistor Apr 26 at 8:50

I've successfully used NITZ during initialisation, and CCLK when I want to read the internal RTC. HOWEVER it can take a minute or two before the modem RTC is set from the network. It's worth maintaining a flag to indicate if the time is indeed valid.

I developed a firmware for a U-Blox LTE. There I used the AT+CCLK? to obtain the current local time from the modem.

It gives a time in following format. Not that it's a synchronized command.

+CCLK: "00/01/01,05:44:53+00" (might get unsynchronized time if the modem time is not sync with the system time)


So the following AT command was sent prior to the registration, to sync the time with the network

AT+CTZU=1\r\n


So my command sequence is:

AT+CTZU=1\r\n
AT+CREG=1\r\n (to subscribe for the network registration updates)
AT+CCLK?\r\n (The Time Zone information is provided after the network registration, if the network supports the time
zone information)


Additional logic to ensure that it has the correct time:

It checks the date against 70/01/01 or 00/01/01 (in our case, those are the times that we get if the modem has an invalid time). And if it's invalid it tries periodically every 1 minute till it gets a correct time. After few retries stops sending CCLK? and rely on other time sources.

Note: NITZ is supported in limited set of countries yet (https://en.wikipedia.org/wiki/NITZ)

So it's best to have a backup way of updating time if it's not supported in that country.

In my case we have GPS module so I obtain time updates through GNSS data.

Additionally, which is not relevant here, but thought useful for time synchronisation.

We run chrony deamon to update the system time (manual commands enabled). So both time updates are fetched and chrony decides the correct time and updates the system time.