列出项目时间戳记问题 [英] list items timestamping issue

查看:95
本文介绍了列出项目时间戳记问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义列表(论坛)和一列(最后一个主题)作为日期时间类型.将一个项目添加到列表中,我希望在gridview标签控件中显示诸如"1小时32分钟前"之类的列表项目的时间戳记

i created a custom list(Forum) and a column(Last topics) as type of datetime.An item is added to the list i want to display timestamping for list items like "1 hour 32 minutes ago" in gridview label control

推荐答案

在Gridview标签控件中显示时间戳,例如"1小时32分钟前"之类的列表项
您需要
1.获取该商品的日期时间数据
2.从Now(现在的日期时间,使用DateTime.Now)获取datetime的差值
3.根据需要以定义的格式使用差异.

日期时间的差异将作为时间跨度存储/跟踪.暴露的属性将直接为您提供相差多少天/小时/分钟.
请参考: MSDN:时域结构 [
display timestamping for list items like "1 hour 32 minutes ago" in gridview label control
You need to
1. fetch the datetime data for that item
2. Get the difference in datetime from Now (current datetime using DateTime.Now)
3. Use the difference in a defined format as per your need.

Difference of Datetime will be stored/tracked as TimeSpan. There are properties exposed that will directly give you how much days/hours/minutes in the difference.
Refer: MSDN: TimeSpan Structure[^]

Try!


这篇关于列出项目时间戳记问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆