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...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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 |
| |||
| <%@ 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> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |