I am trying to format a ten-digit Unix timestamp (currently a string) using ctime.
However, ctime () expects a parameter of type time_t, not a string.
What should I do before I can use ctime? In other words, can I easily convert a string to time_t?
You say you have something like 1346426869 as a string and want it to be time_t?
time_t raw_time = atoi("1346426869"); printf("current time is %s",ctime(&raw_time)); > current time is Fri Aug 31 11:27:49 2012
The time_t type is an integer. This is the number of seconds since the Age. First you need to parse the string.
Start here:
http://www.gnu.org/software/libc/manual/html_node/General-Time-String-Parsing.html#General-Time-String-Parsing
and make your way from there.
Source: https://habr.com/ru/post/924656/More articles:A dash that prevents line breaks between two words - htmlhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/924652/commit-failed-repository-uuid-doesnt-match-expected-uuid-when-committing-to-google-code-from-eclipse-on-windows&usg=ALkJrhi-gFTi8k2L4a219oK0wfYVuL_ckAList of models in the MVC model - c #why decorate Jinja2 instances with @ webapp2.cached_property - propertiesHow to update embedded documents in Doctrine MongoDB? - phpSimulate stack view in Android 2 (API 5)? - androidWhich thread will be the first to enter the critical section? - multithreadingDebugging Perl Programs in KDevelop - debuggingVIM: find and replace reuse token - vimhow to output xlsx generated by openpyxl to browser? - pythonAll Articles