<?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>set timestamp</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/124040/set-timestamp</link><description>Hi,Team, 
 I&amp;#39;m currently using the nrf54l15-dk. I want to set the rtc of the nrf54l15-dk to obtain the timestamp. How should I configure the timestamp ? Which examples should I refer to? My ncs version is v3.0.2. 
 The function I want to achieve is: The</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 15 Sep 2025 16:15:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/124040/set-timestamp" /><item><title>RE: set timestamp</title><link>https://devzone.nordicsemi.com/thread/548785?ContentTypeID=1</link><pubDate>Mon, 15 Sep 2025 16:15:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:579c68e0-fb43-4fee-b321-855bf613b858</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/boards/nordic/system_off/README.html#nrf_system_off"&gt;System Off sample&lt;/a&gt; has the basic framework for entering and waking from system off, and is therefore a good sample to start off of for a prototype. You can enable some statistics in that sample, through configuring &lt;code&gt;CONFIG_APP_USE_RETAINED_MEM=y&lt;/code&gt;. However, out-of-the-box that sample only accumulates uptime, and not sleep time.&lt;/p&gt;
&lt;p&gt;In order to get the total time lapsed on the nRF54L15, since system boot, you can use &lt;a href="https://docs.nordicsemi.com/bundle/nrfx-apis-latest/page/group_nrfx_grtc.html#ga800530da5b26de0ee68736df4cfdb362"&gt;nrfx_grtc_syscounter_get()&lt;/a&gt;. It provides the number of microseconds lapsed on the SYSCOUNTER of the GRTC. The GRTC can operate through System Off, and update the SYSCOUNTER accordingly after wake-up from System Off. See&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/chapters/power-and-clock/reset/doc/reset.html#ariaid-title11"&gt;Reset behavior&lt;/a&gt; for more information on which reset sources resets the GRCT (marked with an &amp;#39;x&amp;#39; in the table) and which reset sources do not (blank).&lt;/p&gt;
&lt;p&gt;Please note that the accuracy of the GRTC value is subject to the accuracy of the clock source, which in System Off mode will be the internal low frequency timer of the nRF54L15.&lt;/p&gt;
&lt;p&gt;An additional benefit of looking at the System Off sample, is that it also shows how to retain data through System Off. In order to keep track of the time and date, you need to keep track of the time difference between the SYSCOUNTER and the real time and date. In practice, you can do this by storing the time and date when the SYSCOUNTER started. Then add to this time and date the time passed according to SYSCOUNTER in order to get the current time and date.&lt;/p&gt;
&lt;p&gt;For conversion between timestamps and date formats, the best would be to find an existing library. There are way too many pitfalls if trying to implement this on your own, such as time zones, leap years, leap seconds, etc., etc. Typically time and date information is stored in UNIX timestamps, which are the number of seconds passed since January 1st 1970. This should be easy to work with since you do have a seconds counter (or microseconds counter) from the GRTC. There are good libraries (e.g. POSIX) for working on dates, which can convert to and from UNIX timestamps and to and from various time formats.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>