Re: Time Conversion



moni,

You could do the conversion manually. You could do this to get the base
time:

DateTime base = new Date(1970, 1, 1);

And then convert the time from time_t to this:

// The date time in time_t format.
int time_t = ...;

// The time span.
TimeSpan span = TimeSpan.FromSeconds(time_t);

// The date time.
DateTime dateTime = base + span;

Note, you could call the AddSeconds method here on the base instance and
get a new DateTime as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx



"moni" <mons.2110@xxxxxxxxx> wrote in message
news:1158588217.265919.224950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I wanted to convert a time value in the form of time_t into a readable
form in C# or vice versa, in order to be able to subtract two time
values and give the result in msecs.

eg.

I have a time value,

1013120149
which is Time in seconds since UTC 1/1/70 in theory.

I need to convert this into,

11:06:31 this form.

or vice vera , i.e from the readable form into the Time in seconds
since UTC 1/1/70.

ANy help would be gr8.

Thanks.



.



Relevant Pages

  • Re: Time Conversion
    ... You could do the conversion manually. ... TimeSpan span = TimeSpan.FromSeconds; ... DateTime dateTime = base + span; ... which is Time in seconds since UTC 1/1/70 in theory. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: UTC dates in SQL 2000
    ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. ... > This db provides dates, which the developer > identifies as UTC, in the format 99999. ... > getutcdatefunction to return the datetime for the> current UTC, or I can CONVERTto convert a> datetime into UTC, but neither will work in an ActiveX> script. ...
    (microsoft.public.sqlserver.dts)
  • Re: ToFileTime vs ToFileTimeUtc issues
    ... "Previous versions of the ToFileTime method assume the current DateTime ... DateTime object is a local time, a UTC time, or an unspecified kind of time ... .", dt, ftLastWriteTime); ... System.DateTime dtLastWriteTimeUtc; ...
    (microsoft.public.dotnet.framework)
  • Re: Web services and incorrect handling of time zones in DateTime
    ... You are not the first one writing this, I think that it is an error by design. ... when the SOAP message contains datetime like ... exactly the same time as previously, but in UTC), it becomes DateTime ... the UTC time should be converted to local time ...
    (microsoft.public.dotnet.general)
  • How do I set the DateTimeMode property when filling a DataTable
    ... I am investigating how best to manage UTC timestamps in ADO.Net. ... ran into a lot of issues with UTC DateTime serialization in .NET 1.1. ... Here is my test code. ... SqlConnection conn = new ...
    (microsoft.public.dotnet.framework.adonet)