语言

Menu
Sites
Language
Get specified time and date

Is that possible to make with default main.js. I dont want to use any random librarys with this. I just want to specified time / date.. If someone can shows to easiest way to make this.. Thanks! :)

var startTime;
var checkTime;

//Initialize function
var init = function () {
    // TODO:: Do your initialization job
    console.log("init() called");

    // add eventListener for tizenhwkey
    document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back")
            tizen.application.getCurrentApplication().exit();
    });
};
// window.onload can work without <body onload="">
window.onload = init;

function startTime() {
    var today = new Date();
    var h = today.getHours();

    var m = today.getMinutes();
    var s = today.getSeconds();
    m = checkTime(m);
    s = checkTime(s);
    document.getElementById('divbutton1').innerHTML="Current time: " + h + ":" + m + ":" + s;
    t = setTimeout(startTime, 250);
}

function checkTime(i) {
    if (i < 10) {
        i="0" + i;
    }
    return i;
}

 

响应

2 回复
Lakshmi Grandhi

Hi.

 

For more information go through the help

https://developer.tizen.org/dev-guide/2.2.0/

 

Alexander AVSukhov