# Legato startup date change?

**URL:** <https://forum.legato.io/t/legato-startup-date-change/4238>\
**Category:** Legato Application Framework\
**Created:** [April 1, 2019, 10:23am UTC](https://forum.legato.io/t/legato-startup-date-change/4238 "2019-04-01T10:23:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)\
**Post date:** [April 1, 2019, 10:23am UTC](https://forum.legato.io/t/legato-startup-date-change/4238/1 "2019-04-01T10:23:37Z")

</div>

Hello,

When legato system starts default date is Jan 1. 1970. and I would like the date to be set to some other before my application starts.  
I know I can set time trough my application by using “le\_rtc\_interface.h” API, but because I’m running my app in couple of processes I’d like the time to be already set inbefore they are started.

How can this be achieved?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 1, 2019, 12:24pm UTC](https://forum.legato.io/t/legato-startup-date-change/4238/2 "2019-04-01T12:24:39Z")

</div>

You can set the apps to be started manually and write a script to start the apps according to your preference.

---

<div class="post-metadata">

**Author:** ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)\
**Post date:** [April 1, 2019, 1:49pm UTC](https://forum.legato.io/t/legato-startup-date-change/4238/3 "2019-04-01T13:49:19Z")

</div>

If I understood correctly, you are suggesting to make an app which will set the date/time as I wish and then start my app afterwards. That can work, only downside is having 2 apps instead of 1, is there any other way?  
I was looking in a way of AT commands but couldn’t find any or maybe editing some files in SierraWireless system?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 1, 2019, 5:46pm UTC](https://forum.legato.io/t/legato-startup-date-change/4238/4 "2019-04-01T17:46:06Z")

</div>

Then this might guarantee the time to be already set in before they are started.

---

<div class="post-metadata">

**Author:** ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)\
**Post date:** [April 3, 2019, 8:52am UTC](https://forum.legato.io/t/legato-startup-date-change/4238/5 "2019-04-03T08:52:36Z")

</div>

This application has to be unsandboxed in order to be able to change the time of the system, am I correct? There is no way of changing the time from a sandboxed application?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 3, 2019, 8:55am UTC](https://forum.legato.io/t/legato-startup-date-change/4238/6 "2019-04-03T08:55:49Z")

</div>

can you post your application here?

---

<div class="post-metadata">

**Author:** ![lazzox](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lazzox](https://forum.legato.io/u/lazzox)\
**Post date:** [April 3, 2019, 10:26am UTC](https://forum.legato.io/t/legato-startup-date-change/4238/7 "2019-04-03T10:26:49Z")

</div>

#include “legato.h”  
#include “interfaces.h”

```
// NEW_EPOCH_TIME_IN_MS is 2019. 1. 1. 00:00:00:000
#define NEW_EPOCH_TIME_IN_MS 1546300800000

COMPONENT_INIT
{
	const uint64_t newTime = 1546300800000;
    uint64_t msPastEpochPtr = 0;
    LE_INFO("Getting absolute time");
    le_clk_Time_t timeNow = le_clk_GetAbsoluteTime();
    LE_INFO("The time obtained is: %ld", timeNow.usec);
	le_clk_Time_t newTm;

    if((uint64_t)(timeNow.usec) < (newTime)){
    	LE_INFO("Date is sooner than 2019. 1. 1. it is going to be updated!");
    	newTm.usec = newTime;
    	le_clk_SetAbsoluteTime(newTm);
    }else LE_INFO("Readtime: %lld isn't less than %ld", msPastEpochPtr, newTm.usec);

    timeNow = le_clk_GetAbsoluteTime();
    LE_INFO("The time obtained is: %lld", (uint64_t)timeNow.usec);
}

```

From the log (I shortened it a bit to be easier to see):

```
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: Getting absolute time
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: The time obtained is: 326873
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: Time is less than the 2019. 1. 1. it is going to be updated.
Jan 1 00:31:16 swi-mdm9x28-wp user.err Legato: =ERR= | timetestapp[8169]/framework T=main | LE_FILENAME le_clk_SetAbsoluteTime() 597 | Setting CLOCK_REALTIME for Absolute time is not permitted
Jan 1 00:31:16 swi-mdm9x28-wp user.info Legato: The time obtained is: 327150

```

Question was:

> application has to be unsandboxed in order to be able to change the time of the system, am I correct?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 3, 2019, 10:45pm UTC](https://forum.legato.io/t/legato-startup-date-change/4238/8 "2019-04-03T22:45:20Z")

</div>

Seems the legato documemt already says :

Absolute time can be set by unsandboxed applications using [le\_clk\_SetAbsoluteTime()](https://docs.legato.io/latest/le__clock_8h.html#a4eccd60ca4f915c546f811d3574864a8).
