02-04-2015 12:46 PM
I have 2 strings of the following format that I would like to convert to seconds (since 1900). I need this value to set the t0 on a plot.
Date: "06-30-2014"
Time: "16:06"08"
Is there a CVI function that will do this conversion for me? If not, is there an easy way to do it?
Thanks!
Solved! Go to Solution.
02-04-2015 04:01 PM
This code should do what you want:
#include <formatio.h>
#include <ansi_c.h> static time_t calt; static struct tm tm; static char msg[64]; static int yy, mm, dd, hh, mn, ss; strcpy (msg, "06-30-2014 16:06:08");
// Extract component from date/time string Scan (msg, "%d[x]%d[x]%d[x]%d[x]%d[x]%d", &mm, &dd, &yy, &hh, &mn, &ss);
// Transfer components to a tm struct tm.tm_hour = hh; tm.tm_min = mn; tm.tm_sec = ss; tm.tm_year = yy - 1900; tm.tm_mon = mm - 1; tm.tm_mday = dd;
// Obrtain the calendar time calt = 0; calt = mktime (&tm);
02-05-2015 08:41 AM
Thanks for the help with this.