DateTime.Today 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 날짜를 가져옵니다.
public:
static property DateTime Today { DateTime get(); };
public static DateTime Today { get; }
static member Today : DateTime
Public Shared ReadOnly Property Today As DateTime
속성 값
시간 구성 요소가 00:00:00으로 설정된 오늘 날짜로 설정된 개체입니다.
예제
다음 예제에서는 현재 날짜를 검색 하는 속성을 사용 합니다 Date . 또한 표준 날짜 및 시간 형식 문자열 중 일부를 사용하여 값의 형식을 지정하는 방법을 DateTime 보여 줍니다. 메서드에 대한 세 번째 호출에서 ToString(String) 생성된 출력은 g 형식 지정자를 사용하여 시간 구성 요소(0)를 포함합니다.
using System;
public class Example
{
public static void Main()
{
// Get the current date.
DateTime thisDay = DateTime.Today;
// Display the date in the default (general) format.
Console.WriteLine(thisDay.ToString());
Console.WriteLine();
// Display the date in a variety of formats.
Console.WriteLine(thisDay.ToString("d"));
Console.WriteLine(thisDay.ToString("D"));
Console.WriteLine(thisDay.ToString("g"));
}
}
// The example displays output similar to the following:
// 5/3/2012 12:00:00 AM
//
// 5/3/2012
// Thursday, May 03, 2012
// 5/3/2012 12:00 AM
open System
// Get the current date.
let thisDay = DateTime.Today
// Display the date in the default (general) format.
printfn $"{thisDay}\n"
// Display the date in a variety of formats.
printfn $"{thisDay:d}"
printfn $"{thisDay:D}"
printfn $"{thisDay:g}"
// The example displays output similar to the following:
// 5/3/2012 12:00:00 AM
//
// 5/3/2012
// Thursday, May 03, 2012
// 5/3/2012 12:00 AM
Module modMain
Public Sub Main()
' Get the current date.
Dim thisDay As DateTime = DateTime.Today
' Display the date in the default (general) format.
Console.WriteLine(thisDay.ToString())
Console.WriteLine()
' Display the date in a variety of formats.
Console.WriteLine(thisDay.ToString("d"))
Console.WriteLine(thisDay.ToString("D"))
Console.WriteLine(thisDay.ToString("g"))
End Sub
End Module
' The example displays output similar to the following:
' 5/3/2012 12:00:00 AM
'
' 5/3/2012
' Thursday, May 03, 2012
' 5/3/2012 12:00 AM
설명
.NET Framework 버전 2.0부터 반환 값은 해당 속성이 Kind 반환되는 Local값입니다DateTime.
현재 시간 Today 없이 현재 날짜를 반환하므로 이 속성은 날짜만 사용하는 애플리케이션에서 사용하기에 적합합니다. 자세한 내용은 DateTime, DateTimeOffset, TimeSpan 및 TimeZoneInfo 중에서 선택을 참조하세요. 반면 속성은 TimeOfDay 현재 날짜 없이 현재 시간을 반환하고 속성은 Now 현재 날짜와 현재 시간을 모두 반환합니다.