Solved

UNIXTime->SYSTEMTIME

Posted on 1998-11-20
4
604 Views
Last Modified: 2013-12-03
I want a function that reads a SYSTEMTIME structure and returns an integer describing the time in UNIX format , and vice-verca
Thanks
0
Comment
Question by:WxW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 1416221
Which Unix time format do you want to start with, specifically?  time_t?  struct tm?  Something else?  What?

B ekiM


0
 
LVL 6

Author Comment

by:WxW
ID: 1416222
Not a structure
I mean UNIX-Time integer , i.e. starting from 1st January 1970

0
 
LVL 11

Accepted Solution

by:
mikeblas earned 40 total points
ID: 1416223

You need these headers:

#include <winbase.h>
#include <winnt.h>
#include <time.h>

This code will get you a FILETIME:

void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
  // Note that LONGLONG is a 64-bit value
  LONGLONG ll;

  ll = Int32x32To64(t, 10000000) + 116444736000000000;
  pft->dwLowDateTime = (DWORD)ll;
  pft->dwHighDateTime = ll >> 32;
}

Given a time_T, you can get to a SYSTEMTIME with this code as well as the above function:

void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
  FILETIME ft;

  UnixTimeToFileTime(t, &ft);
  FileTimeToSystemTime(&ft, pst);
}

See KB article Q167296 for more information.

B ekiM

0
 
LVL 6

Author Comment

by:WxW
ID: 1416224
Thanks mikeblas , and sorry for the delay , I was never informed from EE for your answer =)
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question