Re: Time Conversion




hey,

I cant exactly get wat you are trying to say,

Could u write a psedo code for conversion from

Time: 1158159610 to readable .

and then subtract that with 11:00:04 to get difference in msecs.

It would be really helpful Thanks.




Nicholas Paldino [.NET/C# MVP] wrote:
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
    ... TimeSpan span = TimeSpan.FromSeconds; ... DateTime dateTime = base + span; ... form in C# or vice versa, in order to be able to subtract two time ... which is Time in seconds since UTC 1/1/70 in theory. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SQL bug, ISNULL function with smalldatetime
    ... didn't even think about the rounding and re-implicit conversion to ... >>For @dateParam, ... >>DECLARE @dateParam datetime ... > smalldatetime, rounded to the nearest full minute: 2005-02-10T00:54. ...
    (microsoft.public.sqlserver.programming)
  • Re: Formatting DateTime with an offset
    ... DateTime a is sealed value type so you can not extend it. ... would like my users to be able to specify their prefered TimeZone. ... I have written the code to do the timezone conversion. ... rather have DateTime.ToString go through some kind of formatting that ...
    (microsoft.public.dotnet.framework.aspnet)
  • Formatting DateTime with an offset
    ... I have an application that stores all DateTime inforamtion in UTC. ... would like my users to be able to specify their prefered TimeZone. ... I have written the code to do the timezone conversion. ... rather have DateTime.ToString go through some kind of formatting that ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Age Calculation
    ... Is there another way of taking a datetime field and calculate age in a SQL ... >> I'm trying to create an update query that updates a field to the persons ... >> logic below works perfectly in a Select statement, but I get a conversion ...
    (microsoft.public.sqlserver.dts)