Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > time_t

Reply
Thread Tools

time_t

 
 
magix
Guest
Posts: n/a
 
      09-29-2006
I saw below code:

std::time_t now;
std::time ( &now );
std::stringstream stream;
stream << "output_" << asctime(localtime( &now )) << ".txt" <<
std::flush;

How to convert asctime(localtime( &now )) to be timestamp format like
20060930130102 ?

Thanks & Regards.


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-29-2006
magix wrote:

> How to convert asctime(localtime( &now )) to be timestamp format like
> 20060930130102 ?


strftime()

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
 
Gavin Deane
Guest
Posts: n/a
 
      09-29-2006

magix wrote:
> I saw below code:
>
> std::time_t now;
> std::time ( &now );
> std::stringstream stream;
> stream << "output_" << asctime(localtime( &now )) << ".txt" <<
> std::flush;
>
> How to convert asctime(localtime( &now )) to be timestamp format like
> 20060930130102 ?


How about this:

#include <ctime>
#include <sstream>
#include <string>

int main()
{
std::time_t now;
std::time ( &now );
std::stringstream stream;
stream << "output_" << asctime(localtime( &now )) << ".txt" <<
std::flush;

std::string s = stream.str();

// Write code to modify the contents of s to meet your needs.
}

If you have trouble writing the the code to modify the contents of s to
meet your needs, FAQ 5.8 explains how to post a question about code you
are having trouble with.
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
Follow all those guidelines and you will get the help you need.

What you will have a lot less luck finding of course is anyone who will
donate their time and effort to write all your code for you. Depending
on whether this is your own programming project or something for a
class or school, asking others to do your work for you without showing
how you've attempted it yourself and where you got stuck is called
either laziness or cheating.

Gavin Deane

 
Reply With Quote
 
magix
Guest
Posts: n/a
 
      09-29-2006

"Phlip" <(E-Mail Removed)> wrote in message
news:Bc9Tg.163$(E-Mail Removed)...
> magix wrote:
>
>> How to convert asctime(localtime( &now )) to be timestamp format like
>> 20060930130102 ?

>
> strftime()
>
> --
> Phlip
> http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
>
>


Thanks. this is exactly what I'm looking for.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
borland time_t conversion Tomas Deman C Programming 1 06-07-2004 01:17 PM
DateTime to time_t bug =?Utf-8?B?TWFyaw==?= ASP .Net 2 05-18-2004 06:11 AM
time_t in seconds j0mbolar C Programming 6 04-19-2004 04:14 PM
Casting (time_t)(-1) Dave Sinkula C Programming 4 03-02-2004 03:58 PM
converting to time_t Anand CS C Programming 1 07-03-2003 03:42 PM



Advertisments