By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

time_t

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a

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

P: n/a

"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.