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

Recommended Answers

All 8 Replies

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

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...


We appreciate your help. Have you ever noticed that the current thread is four years old? Please do not resurrect old threads or solved threads.
If you want to ask question, start your own thread.

Have a look at forum rules.
Please read before posting - http://www.daniweb.com/forums/thread78223.html

Thread Closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.