Solved

UNIXTime->SYSTEMTIME

Posted on 1998-11-20
4
597 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now