printing time in HH:MM:SS:MS format

This is a discussion on printing time in HH:MM:SS:MS format within the Linux Programming forums, part of the Platform Specific Boards category; hi all, i want to print time in HH:MM:SS:MS<millisec> format... how to do?? Thanks in advance.... ./senthil...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    19

    Post printing time in HH:MM:SS:MS format

    hi all,


    i want to print time in HH:MM:SS:MS<millisec> format... how to do??

    Thanks in advance....

    ./senthil
    Last edited by msenthil; 10-24-2007 at 02:02 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    Where are you reading time from, and in what format?

    Apart from milliseconds, I would use time.h and strftime().
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    19
    using date command im reading time.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Well then look at the date man page. Something like this
    Code:
    date '+&#37;H:%M:%S'
    gives you HH:MM:SS. I don't see an option for milliseconds.

    Why are you using the date command, anyway? It's not very portable, and depending on how you are executing it, probably slow.

    Consider using some functions from time.h. There are also unportable Linux functions that return milliseconds, but I can't recall their names at the moment.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 08:51 PM
  2. Printing the data in the right format
    By c_geek in forum C Programming
    Replies: 48
    Last Post: 12-24-2007, 04:19 PM
  3. What is the best way to record a process execution time?
    By hanash in forum Linux Programming
    Replies: 7
    Last Post: 03-15-2006, 07:17 AM
  4. How to read in time format?
    By witchiz brews in forum C Programming
    Replies: 1
    Last Post: 02-12-2006, 02:10 AM
  5. relating date....
    By Prakash in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 10:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21