Public Function GetDate() As String
'获取时间
Dim szDate As String
szDate = CStr(Year(Today))
If Len(CStr(Month(Today))) < 2 Then
szDate = szDate & "0 " & CStr(Month(Today))
Else
szDate = szDate & CStr(Month(Today))
End If
If Len(CStr(VB.Day(Today))) < 2 Then
szDate = szDate & "0 " & CStr(VB.Day(Today))
Else
szDate = szDate & CStr(VB.Day(Today))
End If
GetDate = szDate
End Function
有没有高手把这段代码用C#写出来。 感激。。
------解决方案--------------------------------------------------------
DateTime.Now.ToString( "yyyy-MM-dd ")
------解决方案--------------------------------------------------------
public string GetDate(DateTime dt)
{
return dt.ToString( "yyyy-MM-dd ");
}