dealing with Date()

Posted on
  • So I want to find the time between two times.
    The best way I have seen to do this is to just work out diff between two Date types i.e.
    dif old_Date - New Date();
    To do this I need to make an old_Date but I am not sure what the format really is on the bangle for date.
    sorry if this is a simple question. I don't normally code in java.

  • Tue 2021.04.06

    'I don't normally code in java.'

    To clarify:

    Espruino runs a Javascript interpreter.

    Java is a Sun Microsystems compiler language.

    Date:

    Reference may be found at:

    https://banglejs.com/reference#Date

    http://www.espruino.com/Reference#Date

    Example code block:

    http://www.espruino.com/clock#line=12

    Interactive tutorial:

    https://www.w3schools.com/js/js_dates.as­p

  • Hi! What actually happens with Date - Date is when you try and convert Date into a number it gives you the milliseconds since 1970 - so you could just replace one of the dates with that.

    Otherwise to create a Date you can do new Date(args) where args is either nothing (current time), one numeric argument (milliseconds since 1970), a date string (see Date.parse), or [year, month, day, hour, minute, second, millisecond].

    If supplying a String you can do '2011-10-20T14:48:00', '2011-10-20' or 'Mon, 25 Dec 1995 13:30:00 +0430'

    Hope that's some help!

  • Thanks that is just what I needed.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

dealing with Date()

Posted by Avatar for DrBard @DrBard

Actions