VC have what API calculate 1970 years of milliseconds to turn to the current time

Source: Internet
Author: User
Tags filetime

VC has what API calculate 1970 years of milliseconds to convert to the current time, such as Java has simpledateformat.format can be a longlong type of value, such as 1306334020009 to May 2011 x days, x, x format.

void Millisecondsince1970tosystemtime (Longlong nmillisecond, SYSTEMTIME *lpsttime)
{
	large_integer litime;
	Litime.quadpart = Nmillisecond;
	First convert to 100 microseconds unit of FILETIME
	Litime.quadpart *= 10000;
	FILETIME was started in 1960 and needs to be converted with 1970
	Litime.quadpart + = 116444736000000000;
	Convert to SystemTime
	:: FileTimeToSystemTime ((lpfiletime) &litime, lpsttime);

int _tmain (int argc, _tchar* argv[])
{
	//Get current time analog input data
	longlong nfiletime;
	SYSTEMTIME sttime
	:: Getlocaltime (&sttime);
	:: SystemTimeToFileTime (&sttime, (lpfiletime) & Nfiletime);
	Nfiletime-= 116444736000000000;
	Nfiletime/= 10000;

	Call conversion function
	Millisecondsince1970tosystemtime (nfiletime, &sttime);

	Output string
	::p rintf ("%04d-%02d-%02d%02d:%02d:%02d",
		sttime.wyear, Sttime.wmonth, Sttime.wday
		, Sttime.whour, Sttime.wminute, sttime.wsecond);
Reference: https://bbs.csdn.net/topics/360244981


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.