none
Using VB and VS 2015 - Need system time 3:00pm not 15:00pm RRS feed

Answers

  • How are you currently obtaining the time? Also 3PM equates to 15:00 not 3AM.

    Two basic choices

    Console.WriteLine(Now.ToString("hh:mm:ss tt"))
    Console.WriteLine(Now.ToShortTimeString)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites



    Friday, January 12, 2018 11:47 PM
    Moderator
  • Thanks  Label1.Text = Now.ToShortTimeString gave me what I wanted.


    Edcal

    Saturday, January 13, 2018 12:34 AM

All replies

  • How are you currently obtaining the time? Also 3PM equates to 15:00 not 3AM.

    Two basic choices

    Console.WriteLine(Now.ToString("hh:mm:ss tt"))
    Console.WriteLine(Now.ToShortTimeString)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites



    Friday, January 12, 2018 11:47 PM
    Moderator
  • How do I get the system time to be 3:00 PM instead of 15:00 PM

    Edcal

    Hi

    Maybe this is what you want:

    Dim TimeNow As String = Now.ToString("hh:mm tt")
    


    Regards Les, Livingston, Scotland

    Friday, January 12, 2018 11:49 PM
  • How do I get the system time to be 3:00 PM instead of 15:00 PM

    Edcal


    Use DateTime.Now:

    Public Class Form1
        Private Sub _
            Form1_Load(sender As System.Object, _
                       e As System.EventArgs) _
                       Handles MyBase.Load
    
            Dim dt As DateTime = Now
    
            Stop
    
        End Sub
    End Class


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, January 12, 2018 11:51 PM
  • How do I get the system time to be 3:00 PM instead of 15:00 PM

    Edcal

     Is 3:00 PM the local time?  I have never seen 15:00 PM but,  I have seen 15:00 with no AM/PM so, I am not sure how you are getting the time.  Maybe try using the DateTime.Now.ToShortTimeString if you need to display the local time in a Text property of a control.  Or you can use the DateTime.Now.ToString() method and use the time format strings you want.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Label1.Text = Now.ToShortTimeString
            Label2.Text = Now.ToString("hh:mm tt")
            Label3.Text = Now.ToString("h:mm tt")
        End Sub
    End Class
     

     

      Well,  once again with the slow posting.  Sorry for repeating what has been said already.  8)


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, January 13, 2018 12:01 AM
    Friday, January 12, 2018 11:58 PM
  • Thanks  Label1.Text = Now.ToShortTimeString gave me what I wanted.


    Edcal

    Saturday, January 13, 2018 12:34 AM
  • Thanks  Label1.Text = Now.ToShortTimeString gave me what I wanted.


    Edcal


     Shouldn't you have marked one or more of the Posts that actually answered your question as the answers instead of marking your own post as the answer?  You seem to have a habit of not marking the correct posts as answers or just not marking any answer such as in Your Last Question About The MonthCalandsr At This Link.

    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, January 13, 2018 12:53 AM
    Saturday, January 13, 2018 12:46 AM
  • Sorry, I did not understand.

    Edcal

    Saturday, January 13, 2018 8:57 AM