strptime() equivalent on Windows?

If you don’t want to port any code or condemn your project to boost, you can do this:

  1. parse the date using sscanf
  2. then copy the integers into a struct tm (subtract 1 from month and 1900 from year — months are 0-11 and years start in 1900)
  3. finally, use mktime to get a UTC epoch integer

Just remember to set the isdst member of the struct tm to -1, or else you’ll have daylight savings issues.

Leave a Comment