zoukankan      html  css  js  c++  java
  • 随笔


    DateTime.Now.ToLocalTime().ToString();                // 2009-9-5 20:12:12

    //获取日期
    DateTime.Now.ToLongDateString().ToString();     // 2009年9月5日
    DateTime.Now.ToShortDateString().ToString();        // 2009-9-5
    DateTime.Now.ToString("yyyy-MM-dd");                 // 2009-09-05     
    DateTime.Now.Date.ToString();                             // 2009-9-5 0:00:00
    DateTime.ToFileTime().ToString();                     // 128650040212500000
    DateTime.Now.ToFileTimeUtc().ToString();         // 128650040772968750
    DateTime.Now.ToOADate().ToString();                 // 39695.8461709606
    DateTime.Now.ToUniversalTime().ToString();

    //获取时间
    DateTime.Now.ToLongTimeString().ToString();        // 20:16:16
    DateTime.Now.ToShortTimeString().ToString();        // 20:16     
    DateTime.Now.ToString("hh:mm:ss");                 // 09:05:57     
    DateTime.Now.TimeOfDay.ToString();                    // 20:33:50.7197500

    //其他
    DateTime.ToFileTime().ToString();                    // 128650040212500000
    DateTime.Now.ToFileTimeUtc().ToString();        // 128650040772968750
    DateTime.Now.ToOADate().ToString();                 // 39695.8461709606
    DateTime.Now.ToUniversalTime().ToString();        // 2009-5-912:19:14

    DateTime.Now.Year.ToString();                     //获取年份2009     
    DateTime.Now.Month.ToString();                 //获取月份    5     
    DateTime.Now.DayOfWeek.ToString();            //获取星期Thursday
    DateTime.Now.DayOfYear.ToString();            //获取第几天248     
    DateTime.Now.Hour.ToString();                     //获取小时20    
    DateTime.Now.Minute.ToString();                 //获取分钟31     
    DateTime.Now.Second.ToString();                //获取秒数45

    //n为一个数,可以数整数,也可以是小数

    dt.AddYears(n).ToString();        //时间加n年     
    dt.AddDays(n).ToString();        //加n天     
    dt.AddHours(n).ToString();        //加n小时     
    dt.AddMonths(n).ToString();        //加n个月     
    dt.AddSeconds(n).ToString();        //加n秒     
    dt.AddMinutes(n).ToString();        //加n分
  • 相关阅读:
    跳出iframe
    leetcode 225. Implement Stack using Queues
    leetcode 206. Reverse Linked List
    leetcode 205. Isomorphic Strings
    leetcode 203. Remove Linked List Elements
    leetcode 198. House Robber
    leetcode 190. Reverse Bits
    leetcode leetcode 783. Minimum Distance Between BST Nodes
    leetcode 202. Happy Number
    leetcode 389. Find the Difference
  • 原文地址:https://www.cnblogs.com/longshen/p/1667073.html
Copyright © 2011-2022 走看看