How can one format the time in order of increasing precision:

Year Month Day hour:min:sec.millisec
ie. 2006 6 5 11:40:35.456

Right now I have this setup that results in: Fri May 26 13:03:30.451

struct _timeb g_tstruct;

_ftime( &g_tstruct );

fprintf(LogFile, "%.19s.%hu\n", ctime( & ( g_tstruct.time ) ),
g_tstruct.millitm );

and have seen that another %s could be used to hold the year found from
&g_tstruct[20].

But I haven't been able to find any other formats available.

Thanks,

Re: Format time Year Month Day hour minute second millisecond by Ben

Ben
Tue Jun 06 09:00:39 CDT 2006

Use strftime.

A format specifier of "%Y %#m %#d %H:%M:%S" should give results quite close
to what you asked for (you'll still need the extra printf to get the
milliseconds).

"nik" <nikbaer@gmail.com> wrote in message
news:1149576970.154581.225610@c74g2000cwc.googlegroups.com...
> How can one format the time in order of increasing precision:
>
> Year Month Day hour:min:sec.millisec
> ie. 2006 6 5 11:40:35.456
>
> Right now I have this setup that results in: Fri May 26 13:03:30.451
>
> struct _timeb g_tstruct;
>
> _ftime( &g_tstruct );
>
> fprintf(LogFile, "%.19s.%hu\n", ctime( & ( g_tstruct.time ) ),
> g_tstruct.millitm );
>
> and have seen that another %s could be used to hold the year found from
> &g_tstruct[20].
>
> But I haven't been able to find any other formats available.
>
> Thanks,
>



Re: Format time Year Month Day hour minute second millisecond by William

William
Tue Jun 06 10:12:29 CDT 2006

"nik" <nikbaer@gmail.com> wrote in message
news:1149576970.154581.225610@c74g2000cwc.googlegroups.com...
> How can one format the time in order of increasing precision:

I see that Ben has already answered your question. I'd like to add that on
Windows you can use GetTimeFormat() and GetDateFormat() as well.

Regards,
Will



Re: Format time Year Month Day hour minute second millisecond by nik

nik
Tue Jun 06 14:43:27 CDT 2006

Perfect, Thank you


Ben Voigt wrote:
> Use strftime.
>
> A format specifier of "%Y %#m %#d %H:%M:%S" should give results quite close
> to what you asked for (you'll still need the extra printf to get the
> milliseconds).
>
> "nik" <nikbaer@gmail.com> wrote in message
> news:1149576970.154581.225610@c74g2000cwc.googlegroups.com...
> > How can one format the time in order of increasing precision:
> >
> > Year Month Day hour:min:sec.millisec
> > ie. 2006 6 5 11:40:35.456
> >
> > Right now I have this setup that results in: Fri May 26 13:03:30.451
> >
> > struct _timeb g_tstruct;
> >
> > _ftime( &g_tstruct );
> >
> > fprintf(LogFile, "%.19s.%hu\n", ctime( & ( g_tstruct.time ) ),
> > g_tstruct.millitm );
> >
> > and have seen that another %s could be used to hold the year found from
> > &g_tstruct[20].
> >
> > But I haven't been able to find any other formats available.
> >
> > Thanks,
> >