IT Community - Software Programming, Web Development and Technical Support

How Get Current Date in Seconds c#?

This is a discussion on How Get Current Date in Seconds c#? within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi How Get Current Date in Seconds c#? thnx...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-07-2007, 12:52 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Default How Get Current Date in Seconds c#?

Hi

How Get Current Date in Seconds c#?

thnx
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 04:18 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Post Re: How Get Current Date in Seconds c#?

hi, i think we can get the difference in date in seconds
try this to get the difference in date in seconds

double origin = new DateTime(2003, 1, 1).ToOADate();
// the date you are counting from
// this will be expressed in DAYS.


double now = DateTime.Now.ToOADate();
// today's date -- or whatever your comparison date is.
// also expressed in days.


double diff = Math.Abs(now - origin);
// difference in days between both dates

double diffInSeconds = diff * 86400.0;
// conversion from days to SECONDS (24*60*60)
Response.Write(diffInSeconds.ToString());

for counting future date use double diff = Math.Abs(now + origin);

Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-13-2007, 11:46 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How Get Current Date in Seconds c#?

<%@ Page Language="c#" %>
<script runat="server">
void Page_Load()
{
DateTime myDateTime1 = new DateTime();
Response.Write(myDateTime1);
Response.Write("<br />");

DateTime myDateTime2 = new DateTime(1972,11,4);
Response.Write(myDateTime2);
Response.Write("<br />");

DateTime myDateTime3 = new DateTime(1972,11,4,14,5,0);
Response.Write(myDateTime3);
Response.Write("<br />");

DateTime myDateTime4 = new DateTime(260000000);
Response.Write(myDateTime4);
Response.Write("<br />");
}
</script>
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prefill a text form field with the current date. itbarota HTML, CSS and Javascript Coding Techniques 1 03-18-2008 09:09 PM
Count down in seconds from the current time to the year 2000 itbarota HTML, CSS and Javascript Coding Techniques 1 03-07-2008 02:56 AM
store the current date in a hidden form field. itbarota HTML, CSS and Javascript Coding Techniques 1 02-10-2008 09:36 PM
How can I show the documents last modified date in the format: month, date, year, tim Pvinothkumar HTML, CSS and Javascript Coding Techniques 3 12-28-2007 05:58 AM
How to convert a date to a globally accepted date format, in DOT NET 2005? Archer C# Programming 1 07-25-2007 03:21 AM


All times are GMT -7. The time now is 09:32 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0