Timestring

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • N! Xau

    #1

    Timestring

    Hi,

    timestring() returns current time in format hh:mm:ss.
    Any simple way to get also the fractions of a second? (hh:mm:ss:cc)

    thanks
    N! Xau

  • Crouchie1998

    #2
    Re: Timestring

    If you use the SYSTEMTIME Structure you will be able to get milliseconds

    Imports System.Runtime. InteropServices

    <StructLayout(L ayoutKind.Seque ntial)> _
    Public Structure SYSTEMTIME
    Public wYear As Short
    Public wMonth As Short
    Public wDayOfWeek As Short
    Public wDay As Short
    Public wHour As Short
    Public wMinute As Short
    Public wSecond As Short
    Public wMilliseconds As Short
    End Structure

    Private Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemT ime"
    (ByRef lpSystemTime As SYSTEMTIME)


    Dim sysTime As SYSTEMTIME
    GetSystemTime(s ysTime)
    MessageBox.Show (sysTime.wMilli seconds.ToStrin g())

    The above just shows the milliseconds, as I haven't coded any other part of
    the time. You will be able to do that

    I hope the above helps

    Crouchie1998
    BA (HONS) MCP MCSE


    Comment

    • Armin Zingler

      #3
      Re: Timestring

      "N! Xau" <nxau@hotmail.c om> schrieb[color=blue]
      >
      > timestring() returns current time in format hh:mm:ss.
      > Any simple way to get also the fractions of a second? (hh:mm:ss:cc)[/color]

      DateTime.Now returns the current time. Format it any way you want using the
      return value's ToString method.

      "See also:"
      http://msdn.microsoft.com/library/en...matstrings.asp

      Armin

      Comment

      • Cor Ligthert

        #4
        Re: Timestring

        N,

        I am curious, time strings are mostly based on typed text otherwise there is
        a datetime structure choosen. By instance the ticks, which is a long value,
        representing in dotNet the dateTime from the start of the time accoording to
        the Georgian calandar.

        Are people where you live able to type in fractions of seconds?

        Cor


        Comment

        • AMercer

          #5
          RE: Timestring

          Try this:
          Now.ToString("y yyy-MM-dd HH:mm:ss.ff")

          "N! Xau" wrote:
          [color=blue]
          > Hi,
          >
          > timestring() returns current time in format hh:mm:ss.
          > Any simple way to get also the fractions of a second? (hh:mm:ss:cc)
          >
          > thanks
          > N! Xau
          >
          >[/color]

          Comment

          • N! Xau

            #6
            Re: Timestring

            AMercer:
            [color=blue]
            > Try this:
            > Now.ToString("y yyy-MM-dd HH:mm:ss.ff")[/color]


            Here we go!!!

            THANKS

            N! Xau
            keep in mind the power of Antani


            Comment

            • Chris Dunaway

              #7
              Re: Timestring

              Why go through all that trouble?

              DateTime.Now.To String("yyyy-MM-dd HH:mm:ss.ff")

              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Timestring

                "Crouchie19 98" <crouchie1998@s pamcop.net> schrieb:[color=blue]
                > Private Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemT ime"[/color]

                The alias is not really useful ;-).

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://classicvb.org/petition/>

                Comment

                • Chris Dunaway

                  #9
                  Re: Timestring

                  Why go through all that trouble?

                  DateTime.Now.To String("yyyy-MM-dd HH:mm:ss.ff")

                  Comment

                  • Herfried K. Wagner [MVP]

                    #10
                    Re: Timestring

                    "Crouchie19 98" <crouchie1998@s pamcop.net> schrieb:[color=blue]
                    > Private Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemT ime"[/color]

                    The alias is not really useful ;-).

                    --
                    M S Herfried K. Wagner
                    M V P <URL:http://dotnet.mvps.org/>
                    V B <URL:http://classicvb.org/petition/>

                    Comment

                    Working...