471,831 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

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 14049
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 YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.