zoukankan      html  css  js  c++  java
  • c# datetime formater

    using C = System.Console; 
    ...
    static void Main() {
       DateTime dateTime = DateTime.Now;
       C.WriteLine ("d = {0:d}", dateTime );  // mm/dd/yyyy
       C.WriteLine ("D = {0:D}", dateTime );  // month dd, yyyy
       C.WriteLine ("f = {0:f}", dateTime );  // day, month dd, yyyy hh:mm 
       C.WriteLine ("F = {0:F}", dateTime );  // day, month dd, yyyy HH:mm:ss AM/PM 
       C.WriteLine ("g = {0:g}", dateTime );  // mm/dd/yyyy HH:mm
       C.WriteLine ("G = {0:G}", dateTime );  // mm/dd/yyyy hh:mm:ss
       C.WriteLine ("M = {0:M}", dateTime );  // month dd
       C.WriteLine ("R = {0:R}", dateTime );  // ddd Month yyyy hh:mm:ss GMT
       C.WriteLine ("s = {0:s}", dateTime );  // yyyy-mm-dd hh:mm:ss (Sortable)
       C.WriteLine ("t = {0:t}", dateTime );  // hh:mm AM/PM
       C.WriteLine ("T = {0:T}", dateTime );  // hh:mm:ss AM/PM
     
       // yyyy-mm-dd hh:mm:ss (Sortable)
       C.WriteLine ("u = {0:u}", dateTime );  
     
       // day, month dd, yyyy hh:mm:ss AM/PM
       C.WriteLine ("U = {0:U}", dateTime );
     
       // month, yyyy (March, 2006)
       C.WriteLine ("Y = {0:Y}", dateTime );  
       C.WriteLine ("Month = " + dateTime.Month); // month number (3)
     
       // day of week name (Friday)
       C.WriteLine ("Day Of Week = " + dateTime.DayOfWeek);     
     
       // 24 hour time (16:12:11)
       C.WriteLine ("Time Of Day = " + dateTime.TimeOfDay);     
     
       // (632769991310000000)
       C.WriteLine("DateTime.Ticks = " + dateTime.Ticks);   
       // Ticks are the number of 100 nanosecond intervals since 01/01/0001 12:00am
       // Ticks are useful in elapsed time measurement.
       }
  • 相关阅读:
    动态规划:DAG-嵌套矩形
    动态规划:LCIS
    动态规划&字符串:最长公共子串
    动态规划:LCS
    动态规划:状压DP-斯坦纳树
    动态规划:数位DP
    JavaScript 正则表达式
    JavaScript 类型转换
    JavaScript typeof, null, 和 undefined
    JavaScript if...Else 语句
  • 原文地址:https://www.cnblogs.com/walkerwang/p/2932875.html
Copyright © 2011-2022 走看看