Connecting Tech Pros Worldwide Forums | Help | Site Map

time_t

magix
Guest
 
Posts: n/a
#1: Sep 29 '06
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.



Phlip
Guest
 
Posts: n/a
#2: Sep 29 '06

re: time_t


magix wrote:
Quote:
How to convert asctime(localtime( &now )) to be timestamp format like
20060930130102 ?
strftime()

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


Gavin Deane
Guest
 
Posts: n/a
#3: Sep 29 '06

re: time_t



magix wrote:
Quote:
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

magix
Guest
 
Posts: n/a
#4: Sep 29 '06

re: time_t



"Phlip" <phlipcpp@yahoo.comwrote in message
news:Bc9Tg.163$NE6.0@newssvr11.news.prodigy.com...
Quote:
magix wrote:
>
Quote:
> 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.


Closed Thread


Similar C / C++ bytes