Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to calculate time difference in source code.

Here is my code:

On
<%=System.DateTime.Now%>&"-"&<%# Eval("Submit_date")%>


but its not working.

I already done this but i have lost my code and now i forget it.
But i think i could do like this but this time its not working.

I want this result like how many hours ago or how many days ago.

please any one help me how can i do this in source code.

Thanks in advance

I also try this:
<%#System.DateTime.Now.Subtract(Convert.ToDateTime(Eval("Submit_date")))%>

But not working, where i can add ToString
Posted
Updated 9-Jun-11 2:31am
v4
Comments
Monjurul Habib 9-Jun-11 18:05pm    
why you need that on client side? just wondering.

try

<%#System.DateTime.Now.Subtract(Convert.ToDateTime(Eval("Submit_date")))%>

Hope it will help.. :)
 
Share this answer
 
v2
Comments
rahul dev123 8-Jun-11 9:00am    
It gives the output like this:
656.07:48:06.7656250
but i want like 1hour ago, 1days ago
Ra-one 9-Jun-11 1:28am    
use .TOString("MMM/dd/yyyy") at the end with the format you want for eg MMM/dd/yyyy;
Ra-one 9-Jun-11 1:28am    
ToString("MMM/dd/yyyy")
rahul dev123 9-Jun-11 5:26am    
If i use ToString it shown some error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900