开发者

Conversion of Coldfusion Date format to C Sharp format

I am trying to convert a coldfusion code to csharp but with little success. Cold fusion code goes as below:

<CFSET iTimeBefore = #TimeFormat( Now(), 'hh:mm:ss tt' )#>
Some DB Operation here...
<CFSET iTimeBefore = #Caller.iTimeBefore#>
<CFSET iTimeAfter = #TimeFormat( Now(), 'hh:mm:ss tt' )#>
<cfset TimeDiff = #iTimeAfter# - #iTimeBefore#>
<CFSET TimeDiff = TimeDiff*100000>
<CFSET TimeDiff = #NumberFormat(TimeDiff, '99.999')#>

Essentially, the code is checkiing for time elapsed while performing DB operation. I have tried to use 'TimeSpan' class in C# 开发者_Go百科but it gives current time as follows:

TimeSpan dtOprnStartTime1 = DateTime.Now.TimeOfDay;

Output:
20:15:12.9661624

Kindly advise.


Try this:

DateTime before = DateTime.Now;

// Some DB Operation here

TimeSpan elapsed = DateTime.Now - before;

Console.Write(elapsed);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜