Well i want to know if there is any code for converting the date time retrived from windows system date to a unix format,

hey you can try this code in C#

double epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; 

this will help to convert current time to unix time stamp.

The offset ( 621355968000000000) is wrong. The correct offset is

const unsigned long long  UnixTimeOffset = ((unsigned long long)(369 * 365 + 89) * 24 * 3600 * 10000000);

See ntfs-3g source code.

Just a tip: Disregard vogu00's message, the offset is indeed correct, using his suggested corrected value (after converting it into proper C# syntax) returns the year 3610 instead of 2010...

just another idea here: I wouldn't use a double to store the epoch value ... this is defined as a long

Edited 6 Years Ago by sushi.at: n/a

Never said his code wouldn't compile in C++.... he labeled it as C# though. And when you run it in C# the offset is wrong. Seems like we got the correct offsets for both languages then...

This article has been dead for over six months. Start a new discussion instead.