언어 설정

Menu
Sites
Language
date.gettime

Hello Guys, 

Anyone can help me to resolve this problem ? "date.getTime()"  not worked on tizen !!! how i can use this code ?

 

      var date= tizen.time.getCurrentDateTime(),
      then = tizen.time.getCurrentDateTime(date.getFullYear(),date.getMonth(),date.getDate(),0,0,0),
      diffInMil = (date.getTime() - then.getTime()),
      horotate = (diffInMil/(1000*60*60)),
      minrotate = (horotate*60),
      secrotate = (minrotate*60);

 

답변 바로가기

Responses

14 댓글
Iqbal Hossain

Hi, 

Please try as below,

  • Get the current time object:

    date = tizen.time.getCurrentDateTime();
  • Get the current weekday (MON - SUN):

    day = date.getDay();
  • Get the current month (0 - 11) and day (1 - 31):

    month = date.getMonth() + 1,
    day = date.getDate();
  • Get the current hour (0 - 23), minutes (0 - 59), and seconds (0 - 59):

    str_hours = date.getHours();
    str_minutes = date.getMinutes();
    str_second = date.getSeconds()

If you find my answer helpful, please mark my answer as best answer. 

aMir Sirati

hello bro,

thanks for your answer, but i need result like as getTime function, 

Sample : http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_gettime

This is my code : 

function draw(){
        var now = new Date(),//now
            then = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0),//midnight
            diffInMil = (now.getTime() - then.getTime()),// difference in milliseconds
            h = (diffInMil/(1000*60*60)),//hours
            m = (h*60),//minutes
            s = (m*60);//seconds
        //rotate the hands accordingly
        sec.style.webkitTransform = "rotate(" + (s * 6) + "deg)";
        hour.style.webkitTransform = "rotate(" + (h * 30 + (h / 2)) + "deg)";
        min.style.webkitTransform = "rotate(" + (m * 6) + "deg)";
    } 

 

Marco Buettner

The method .getTime() is not included in tizen.time... If u want to work with that... u need the native Date object. You can create it with new Date().

Shaswati Saha

Hello,
I have tested your code. You need to do a little change.
 

function draw(){
        var now = new Date(),//now
            then = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0),//midnight
            diffInMil = (now.getTime() - then.getTime()),// difference in milliseconds
            h = (diffInMil/(1000*60*60)),//hours
            m = (h*60),//minutes
            s = (m*60);//seconds
        //rotate the hands accordingly
        window.sec.style.webkitTransform = "rotate(" + (s * 6) + "deg)";
        window.hour.style.webkitTransform = "rotate(" + (h * 30 + (h / 2)) + "deg)";
        window.min.style.webkitTransform = "rotate(" + (m * 6) + "deg)";
    } 

 

aMir Sirati

getTime() not worked in tizen 2.3.1

Shaswati Saha

Did you try getting the value of hour,minute or second in the console? What does it give? Can you share that?
The code snippet in my previous post is working fine in tizen wearable 2.3.1 for me.

aMir Sirati

when i replace Date() with getCurrentDateTime()

var now = tizen.time.getCurrentDateTime(),
        then = tizen.time.getCurrentDateTime(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0),//midnight
        diffInMil = (now.getTime() - then.getTime()),
        h = (diffInMil/(1000*60*60)),

i have an error : TypeError: 'undefined' is not a function (evaluating 'now.getTime()')

 

Marco Buettner

Yeah.. BECAUSE getTime() isnt a method of tizen.time... I wrote it in a previous post... Change your fuckin code Shaswati Saha wrote above... 

aMir Sirati

how are you guys ? :D

aMir Sirati

so is there any way or sample to help me ? :(

Marco Buettner

are u stupid or retard? Shaswati Saha posted your sample ... -.-'

aMir Sirati

lol

Mark as answer
Shaswati Saha

If your requirement is to use only local time then going with new Date() should be fine. You can go with that. 

aMir Sirati

thank you very much bro.