Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:17:28+00:00 2026-05-25T06:17:28+00:00

There is C code : time1=((double)dt1-25569.0)*86400.0; it’s convert from TDateTime (VCL) to time_t format

  • 0

There is C code :

time1=((double)dt1-25569.0)*86400.0;

it’s convert from TDateTime (VCL) to time_t format in seconds, so finally I need to get time_t format from .NET DateTime

about time_t :

It is almost universally expected to be an integral value representing
the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. This
is due to historical reasons, since it corresponds to a unix
timestamp, but is widely implemented in C libraries across all
platforms.

So to get seconds in .NET I’m doing this (F#):

let seconds(dt : DateTime) =
    (dt.Ticks/10000000L)

or on C# (to use more popular C# tag) :

Int64 seonds(DateTime dt)
{ return (dt.Ticks/ ((Int64)10000000)); } 
// hope it works, but please correct if I mistaken

As far as I understand it’s time from 12:00:00 Jan 1, 0001 UTC.

So to use time_t format I need to add 1970 years in seconds.

So final function must be (F#):

let seconds(dt : DateTime) =
    (dt.Ticks/10000000L) + 31536000*1970

C# :

Int64 seonds(DateTime dt)
{ return (dt.Ticks/ ((Int64)10000000)) + 31536000*1970; } 

I really afraid I made mistake here. Please examine this solution ! (check if this is done right)

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:17:29+00:00Added an answer on May 25, 2026 at 6:17 am

    try

     (dt - new DateTime (1970, 1, 1)).TotalSeconds
    

    see

    • http://msdn.microsoft.com/en-us/library/system.timespan.totalseconds.aspx
    • http://msdn.microsoft.com/en-us/library/xcfzdy4x.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are times when I want to test new code from the forums or
Is there a way of calling a method/lines of code multiple times not using
Is there a way to, at compile-time, decide on one of two run-time code
There are a number of run-time differences in compatible code between these two versions
The following line of code generates the compile time error (PE19) There is no
If there was ever a time to hate IE, this is it. This code
I write hobby code from time to time. The thing is these tools, classes
Is there code in VBA I can wrap a function with that will let
There is code for save button, but I can't see any code behind the
I have a type alias in my code like so: type Time = Double

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.