0

time(time field) problem

I'm in NY, EST. 

I have a time field "TF" that says: 2:30 PM 

so  time field TF contains 2:30 PM

if x := TF

then I get x= 9:30 am

 

if x := time(TF)

then alert(x) from a button shows  4:30 AM

 

ultimately, I want to take a date field and a time field and use them to set an appointment field.

If there is a better way, I am open to it.

 

But I still want to know why I am seeing the above.

 

Help, please!!

4 replies

null
    • NYNNA
    • Louis_Cornacchia
    • 3 mths ago
    • Reported - view

    To add details to the above:

    I have two fields:  a date field and a time field. 

    the code is"

    xDate := (DF)   

    xTime := (TF)   

    alert(xDate + xTime)  shows  correct date, incorrect time

     

    however: alert(xTime) displays the correct time. 

     

    Now this becomes an academic discussion. 

    • Fred
    • 3 mths ago
    • Reported - view

    For date and time fields Ninox uses milliseconds (for dates milliseconds since 1970).

    You can see for yourself if you create a new formula field and use the number() command.

    I have a date field (Date) and time field (Time) with the following data:

    Date: 1/17/2024

    Time: 8:27 AM

    If I do number(Date) I get: 1705449600000.

    If I do number(Time) I get: 30420000.

    If I add a date/time field and set it to the same date and time as above I get: 1705508820000.

    But wait if I add the two above I don't get the same number. I get: 1705480020000. Which if you do datetime() of the milliseconds you get: 01/17/2024 12:27 AM. Which is exactly 8 hours off. Which just happens to be my time zone difference, PST. So time is all based on UTC and modified by Ninox to match your time zone.

    So 1 hour = 3,600,000 milliseconds so 8 hours = 28,800,000 ms.

    I can create a new appointment field and a new button with the following code:

    let xstart := number(Date) + (number(Time) + 28800000);
    Appointment := appointment(xstart, 60000 * 60)
    

    And it will create a new appointment that is 1 hour greater than the data in my Date and Time fields.

    Then comes daylight savings...

    • NYNNA
    • Louis_Cornacchia
    • 3 mths ago
    • Reported - view

    That was a very thorough and very edifying explanation. Let me express my gratitude for taking time to provide this. It makes perfect sense. 

    How does ninox know my time zone? Is it manually assigned to my server account? Is it determined from internet time? - My IP?  

    I noticed that there is no manual setting for the time zone. 

      • Fred
      • 3 mths ago
      • Reported - view

      I'm guessing, please correct me if I'm wrong, that your browser knows your time zone based on your computer settings. Same for the MacOS app.

Content aside

  • Status Answered
  • 3 mths agoLast active
  • 4Replies
  • 52Views
  • 2 Following