I have a time_t variable containing a timestamp which I’d like to store in a database, so I need it as a string. How would I convert it?
Also, on the subject, how would I convert a timestamp string into a time_t variable?
Thanks,
Wyatt
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Look at ctime, it takes a time_t and returns a string.
To make a timestamp from a string, look at mktime. Populate the fields of a struct tm and call mktime. It should return a time_t.