468,496 Members | 1,804 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

time_t

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.
Sep 29 '06 #1
3 13848
magix wrote:
How to convert asctime(localtime( &now )) to be timestamp format like
20060930130102 ?
strftime()

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Sep 29 '06 #2

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

Sep 29 '06 #3

"Phlip" <ph******@yahoo.comwrote in message
news:Bc*************@newssvr11.news.prodigy.com...
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.
Sep 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Anand CS | last post: by
4 posts views Thread by Dave Sinkula | last post: by
6 posts views Thread by j0mbolar | last post: by
8 posts views Thread by Ian Pilcher | last post: by
reply views Thread by Zwyatt | last post: by
reply views Thread by Zwyatt | last post: by
8 posts views Thread by Henrik Goldman | last post: by
45 posts views Thread by loudking | last post: by
7 posts views Thread by Nick Keighley | last post: by
8 posts views Thread by Abubakar | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.