How do you recover the number of seconds stored in a DateTime object?

  1. 7 months ago

    Robert L

    1 Nov 2019 XDC Speakers Federal Way, WA (Seattle Area)

    From the Documentation:

    A DateTime object stores the number of seconds since 12:00 AM, January 1, 1970

    Fine. How do I get that value in a Double or whatever.

    Var nowDate As DateTime 
    nowDate = DateTime.Now

    Can I find out how many seconds there have been since 12:00 AM, January 1, 1970?
    i.e. what is the number of seconds that nowDate is storing?

    well according to the LangRef

    dim seconds as double =nowDate.secondsfrom1970
  2. Dave S

    1 Nov 2019 Answer San Diego, California USA

    well according to the LangRef

    dim seconds as double =nowDate.secondsfrom1970
  3. Tim P

    1 Nov 2019 Testers, Xojo Pro Rochester, NY
    Edited 7 months ago

    http://docs.xojo.com/DateTime.SecondsFrom1970

    Edit: by seconds!

  4. Markus R

    2 Nov 2019 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 7 months ago

    (sorry i ask here)
    why it is a double (floating point numbers) and not a long integer???
    because milli seconds?

  5. Ulrich B

    2 Nov 2019 Testers, Xojo Pro Europe (Germany, Berlin) · xo...
    Edited 7 months ago

    @Markus R (sorry i ask here)
    why it is a double (floating point numbers) and not a long integer???
    because milli seconds?

    They could be used for it. But mainly because Double has a much wider range than Int64: max 1.7 x 10^308.

or Sign Up to reply!