<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Update time (UTC) using LTE?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89282/update-time-utc-using-lte</link><description>Hi, 
 I have been looking for some libraries to get current time (UTC) using LTE on the nrf9160. Are there any samples that uses that method? Which libraries do recommend? After receiving time, can you use the time.h library? Can see that several samples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 28 Jun 2022 08:02:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89282/update-time-utc-using-lte" /><item><title>RE: Update time (UTC) using LTE?</title><link>https://devzone.nordicsemi.com/thread/374466?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 08:02:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5d4c8a8-2fc2-4c6d-99f7-b488ffe442d9</guid><dc:creator>Elias</dc:creator><description>&lt;p&gt;This works:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="c_cpp"&gt;void main(void)
{
	int err;
	char response[513];
	int rc;
	
	k_sleep(K_MSEC(2000)); //Just to get time to open LTE Link monitor.

	printk(&amp;quot;Activating LTE... \n&amp;quot;);
	err = lte_lc_init_and_connect(); //BLOCKS until connection.
	if (err) {
		printf(&amp;quot;Failed to connect to the LTE network, err %d\n&amp;quot;, err);
		return;
	}
	printk(&amp;quot;OK!\n&amp;quot;);

	k_busy_wait(1000000); //Don&amp;#39;t know the optimal timestamp
	rc = nrf_modem_at_scanf(&amp;quot;AT+CCLK?&amp;quot;, &amp;quot;+CCLK: %s&amp;quot;, &amp;amp;response);
	
	printf(&amp;quot;rc: %d\n&amp;quot;, rc);
	printf(&amp;quot;Modem response: %s \n&amp;quot;,response);

	nrf_modem_lib_shutdown();
	
	printk(&amp;quot;Turning off LTE\n&amp;quot;);
	lte_lc_power_off();


	
	printk(&amp;quot;SHUTDOWN.\n&amp;quot;);
}&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Not optimized, but will extract the time from the modem in the response string when connected to the LTE network.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update time (UTC) using LTE?</title><link>https://devzone.nordicsemi.com/thread/374156?ContentTypeID=1</link><pubDate>Fri, 24 Jun 2022 12:48:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2327762b-b13a-45eb-a3e3-abd017179c88</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can use the&amp;nbsp;&lt;span&gt;date-time library:&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See the configuration here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html#configuration"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html#configuration&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And samples using this library here:&lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html#samples-using-the-library"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/date_time.html#samples-using-the-library&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update time (UTC) using LTE?</title><link>https://devzone.nordicsemi.com/thread/373975?ContentTypeID=1</link><pubDate>Thu, 23 Jun 2022 14:00:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ff51559-9e5b-48b6-b461-ed7f43265eb4</guid><dc:creator>Elias</dc:creator><description>&lt;p&gt;I have been trying with the date_time.h library, but only get fatal error when building. Example this:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1655992779183v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;gives me an error. Some help?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>