Lockdown customisation (date and time)

BR
Bruno Rame Bronze Contributor
COPPERNIC

On the lockdown, Is it possible to display the date and the time of the device ?

7 years ago
Android
ANSWERS
RC
Raymond Chan Diamond Contributor
7 years ago

You can use javascript and date/time related functions e.g. Date(), getHours(), getMinutes(), etc. to display the date/time in your desired format and update as frequent as you desire.

MD
Matt Dermody Diamond Contributor
7 years ago

I'm assuming your using Android Enterprise with the Kiosk based SOTI Lockdown that is full screen and hides the status bar with the time by default?

Maybe you could change these options in the Kiosk Settings? I made these changes and the Status Bar and time came back. 

After:

BR
Bruno Rame Bronze Contributor
7 years ago

We can display the date and time on the lockdown but we have to refresh manually to update the time.

Lockdown Script used :

<script language="javascript">
document.getElementById("datetime").innerHTML = formatAMPM();

function formatAMPM() {
var d = new Date(),
minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
hours = d.getHours(),
day = d.getDate().toString().length == 1 ? '0'+d.getDate() : d.getDate(),
year = d.getFullYear().toString().substr(-2);
return day+'/'+(d.getMonth()+1)+'/'+year+' '+hours+':'+minutes;

Thanks for your help

C
Christophe Platinum Contributor
7 years ago

Hello Bruno,

you just need to update every second ...

there is a javascript method for to do this : setInterval( METHOD, Millisecond);

Looks at this sample

https://jsfiddle.net/cv8wLgux/

have a nice day

BR
Bruno Rame Bronze Contributor
7 years ago

Hi

In the lockdown, we added the script :

<script language="javascript">
document.getElementById("datetime").innerHTML = formatAMPM();

function formatAMPM() {
var d = new Date(),
minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
hours = d.getHours(),
day = d.getDate().toString().length == 1 ? '0'+d.getDate() : d.getDate(),
year = d.getFullYear().toString().substr(-2);
return day+'/'+(d.getMonth()+1)+'/'+year+' '+hours+':'+minutes;
}


function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
window.onload = timedRefresh(60000);

After 1 minute, the time is updated but a chrome Web page is launched ahead the lockdown.

Thank you for your help