返回当前时间系统的程序 [英] A program that returns the current time system

查看:65
本文介绍了返回当前时间系统的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

返回当前时间系统的程序

A program that returns the current time system

推荐答案

using System;

class Program
{
    static void Main()
    {
	DateTime time = DateTime.Now;              // Use current time
	string format = "MMM ddd d HH:mm yyyy";    // Use this format
	Console.WriteLine(time.ToString(format));  // Write to console
    }
}


Uma Shankar Patel 的解决方案1直截了当.我只想补充一下,ddd d 的格式都给出,打印格式器yyyy指定的日期和年份,通常不会在该时间之后打印.
因此,此处提供的一种标准DateTime格式
标准DateTime格式字符串 [自定义日期和时间格式字符串 [
The Solution 1 by Uma Shankar Patel is straight to the point. I only want to add that both ddd and d given in the format, print the date and year specified by the formatter yyyy, is generally not printed after the time.
So, one of the standard DateTime formats given here
Standard DateTime Format Strings[^]
or one of the custom DateTime format strings given here
Custom Date and Time Format Strings[^]
will be a better option.


请参阅此链接:

http://www.dotnetperls.com/datetime-now [
Refer this link:

http://www.dotnetperls.com/datetime-now[^]


这篇关于返回当前时间系统的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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