473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 14393
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand CS | last post by:
Hi All I have question regarding time data structures... I have 64 bit unsigned microsecond resolution (unsigned __int64 for windows/and unsigned long long for others) variable. It stores the...
4
by: Dave Sinkula | last post by:
I have been told conflicting advice. Please offer comments regarding the following. ===== I visited Ben Pfaff's "When are casts appropriate?" page....
6
by: j0mbolar | last post by:
i've read recently that time_t doesn't have to be in second resolution but if it isn't, then what resolution could it be in? microseconds, milliseconds, are all valid? also, does anyone know...
8
by: Ian Pilcher | last post by:
When adding two values of type time_t, how can I check for overflow? Maybe I'm just brain-cramped today, but I can't figure out how to do it. Thanks! --...
0
by: Zwyatt | last post by:
I have the following code (simplified here): #include <time.h> class A { public: char *aString; int aNum; time_t aTime; }
0
by: Zwyatt | last post by:
having a really weird little bug w/ time_t...check it out: I have the following code (simplified here): #include <time.h> class A { public: char *aString; int aNum;
8
by: Henrik Goldman | last post by:
I have strings like "2006-03-26 21.51" which I would like to convert into time_t. I know that the string is in localtime. So far I've written the following code: time_t...
45
by: loudking | last post by:
Hello, all I don't quite understand what does ((time_t)-1) mean when I execute "man 2 time" RETURN VALUE On success, the value of time in seconds since the Epoch is retu rned. On error,...
7
by: Nick Keighley | last post by:
Hi, this is probably quite easy... How do I convert a UTC string into a time_t? eg. "2007-12-18 13:37:26" - a time_t. Now FAQ 13.3 says use mktime() to convert a struct tm into a time_t...
8
by: Abubakar | last post by:
Hi, Lets say I have three integers (date, month, and year) as part of a struct lets say like struct mydate{ int day, month, year}; I want to add x number of days to this date. And it should be a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.