Reputation: 465
I'm looking for a way to convert, a formated date dd/mm/yyyy to standard timestamp. using c++ language.
thank you for your help
Upvotes: 0
Views: 1180
Reputation: 757
Something like this:
struct tm tm;
time_t epoch;
strptime(your_formated_date, "%d/%m/%Y", &tm);
epoch = mktime(&tm);
Upvotes: 1
Reputation: 279225
strptime
and mktime
.
Be aware that timezone affects the answer, since a standard timestamp is seconds since 1970 UTC, not necessarily seconds since 1970 local time.
Also be aware that the epoch isn't guaranteed by the C++ standard to be 1970, although it is on common systems.
Upvotes: 1