Format - DateTime
1. Long Date/Short Date/Long Time/Short Time,可以在系统的“Region and Language”中找到相应设置;
2. ISO Format/Local Format/UTC Format (注:系统格式为德国时间格式)
- string longDateStr = DateTime.Now.ToLongDateString();
- string shortDateStr = DateTime.Now.ToShortDateString();
- string longTimeStr = DateTime.Now.ToLongTimeString();
- string shortTimeStr = DateTime.Now.ToShortTimeString();
- string localTimeStr = DateTime.Now.ToLocalTime().ToString();
- string utcDateStr = DateTime.UtcNow.ToString();
- string isoTimeStr = DateTime.Now.ToString(@"yyyy-MM-dd\THH:mm:ss\Z");
- Console.WriteLine("Long Date String: " + longDateStr);
- Console.WriteLine("Short Date String: " + shortDateStr);
- Console.WriteLine("Long Time String: " + longTimeStr);
- Console.WriteLine("Long Time String: " + shortTimeStr);
- Console.WriteLine("Local Time String: "+localTimeStr);
- Console.WriteLine("UCT Now String: " + utcDateStr);
- Console.WriteLine("ISO Time String: " + isoTimeStr);
- Console.Read();
得到的结果:
3. SharePoint中的日期进行查询之前,需要先更改为 ISO8601格式的标准日期格式:
- //JavaScript Code
- string startDateFx = startDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
- string endDatFx = endDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
在C#中可以使用 SPUtility.CreateISO8601DateTimeFromSystemDateTime() 来实现;
时间值最后的字母 Z 标识着这个时间属于UTC时间;
4.
Format - DateTime的更多相关文章
- String.Format,DateTime日期时间格式化
DateTime dt = DateTime.Now;//2010年10月4日 17点05分 string str = ""; //st ...
- String Format for DateTime
This example shows how to format DateTime using String.Format method. All formatting can be done als ...
- String Format for DateTime [C#]
This example shows how to format DateTime using String.Format method. All formatting can be done als ...
- C#详解format函数,各种格式化
一.String Format for Double Digits after decimal point This example formats double to string with fix ...
- python字符串格式化方法 format函数的使用
python从2.6开始支持format,新的更加容易读懂的字符串格式化方法, 从原来的% 模式变成新的可读性更强的 花括号声明{}.用于渲染前的参数引用声明, 花括号里可以用数字代表引用参数的序 ...
- datetime中strftime和strptime用法
from datetime import * format = "%Y-%m-%d %H:%M:%S" a=datetime.now() day=a.day b=a.replace ...
- CLR via C# - Char_String - Format
//前面那个本来想重新编辑的,但是那个编辑器之前被我调到Markdown之后,改回Tiny MCE编辑器不出来 1.ToString()方法 & IFormattable & IFor ...
- Python格式化字符串--format
format格式化字符串方法相较于老版%格式方法的优点: 1.不需要理会数据类型的问题,在%方法中'%s'只能替代字符串类型. 2.单个参数可以多次输出,参数顺序可以不相同. 3.填充方式十分灵活,对 ...
- C# 自定义类型通过实现IFormattable接口,来输出指定的格式和语言文化的字符串(例:DateTime)
常规的调用ToString()方法,存在两个问题. (1).调用者无法控制字符串的格式 (2).调用者不能方便的选择一种特定的语言文化来格式化字符串. 在开发一些国际化的应用时,应用程序需要调用与当前 ...
随机推荐
- [USACO07DEC]泥水坑Mud Puddles BFS BZOJ 1627
题目描述 Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the ...
- 单选框radio总结(获取值、设置默认选中值、样式)
单选框 radio <div class="radio-inline"> <input type="radio" name="kil ...
- B - Toy Storage(POJ - 2398) 计算几何基础题,比TOYS多了个线段排序
Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing ...
- c#工具类之Bitmap缩放帮忙类
using System.Drawing; using System.Drawing.Drawing2D; /// <summary> /// BitmapHelper /// </ ...
- IOS不支持overflow: hidden;
IOS不支持overflow: hidden; 假设页面上有个弹出窗,弹出窗出现后,只想让用户的视觉锁定在弹出窗上,正常我们会想到用overflow:hidden这个属性来实现,如下 html{ ov ...
- ecmall模板编辑中的标题如何自定义读取
碰见了一个问题,刚上线的ecmall项目.客户说标题不要商城首页这四个字. 我去源码里找,找了半天才找到. 问题描述如下: 找到title的最原始模板themes\mall\tmall\top.htm ...
- PIE SDK栅格数据集的读写
1. 功能简介 栅格数据包含很多信息,在数据的运用中需要对数据的信息进行读取或写入,目前PIE SDK支持多种数据格式的数据读取和写入,下面对栅格数据格式的数据读写功能进行介绍. 2. 功能实现说明 ...
- DbUtils(二) 结果集实例
单行数据处理:ScalarHandler ArrayHandler MapHandler BeanHandler 多行数据处理:BeanListHandler Abstract ...
- jq api --css
.css() $("p").css("color","red"); $("p").css({ "color&q ...
- MHA 高可用架构部署
一, MHA 介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公 ...