+ Reply to Thread
Results 1 to 2 of 2

Time format

  1. #1
    Registered User
    Join Date
    12-23-2003
    Location
    Belgium
    Posts
    12

    Time format

    Hi,

    I'm using this code to place the time in a cell:

    timestamp = Format(Now(), "hh:mm:ss")

    As a result i get: 4:32:51 PM

    But what i want is 16:32:51

    Who can help me?

  2. #2
    Registered User
    Join Date
    01-20-2004
    Location
    Western NY
    Posts
    99
    I have had mixed results using the Format function. I have had "some" success using capital H's and M's when I wanted 24 hour formats, for example

    Format(Now(),"HH:MM")

    but often the results default to whatever you have set for your system, i.e., 12 hr w/AMPM or 24 hr. I have my computer set to 24 hour time, so I get 24 hour output with either hh:mm or HH:MM (most of the time). When I set my system to 12 hr time, HH:MM sometimes works. I have had mixed results with getting a 4 digit year out of the format function too. When I use Format(datevalue,"dd-mmm-yyyy") and should get, for today, 21-Feb-2005, I often get 21-Feb-05.

    The FormatDateTime has specific formats that work more reliably:

    FormatDateTime(Now(),vbShortTime) has given consistent 24 hour time out even when I set my computer to 12 hour time.

    Hope this helps

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1