“DateTime.parse” Kod odpowiedzi

Parse Datetime Python

from dateutil.parser import parse

datetime = parse('2018-06-29 22:21:41')

print(datetime)
notPlancha

C# ciąg do Datetime

string iDate = "05/05/2005";
DateTime oDate = Convert.ToDateTime(iDate);
MessageBox.Show(oDate.Day + " " + oDate.Month + "  " + oDate.Year );
Gorgeous Gaur

DateTime.parse

string s = "2011-03-21 13:26";
DateTime dt = DateTime.ParseExact(s, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
___________________________________________________________________________________________________________________________________________________________

var    dtStr = "2011-03-21 13:26";
DateTime? dt = dtStr.ToDate("yyyy-MM-dd HH:mm");
___________________________________________________________________________________________________________________________________________________________
// in C#7 only: "DateTime dt;" - no longer required, declare implicitly
 if (DateTime.TryParseExact(dateTimeStr, dateFmt,
     CultureInfo.InvariantCulture, style, out var dt)) result = dt;

// in C#7 only: Declaration of result as a "one-liner" ;-)
 var result = DateTime.TryParseExact(dateTimeStr, dateFmt, CultureInfo.InvariantCulture,
              style, out var dt) ? dt : null as DateTime?;
Ram S

Parse Datetime C#

using System.Globalization;
DateTime.ParseExact("20200101123000", "yyyyMMddHHmmss", CultureInfo.InvariantCulture)
Jerome Choo

ciąg do DateTime C#

DateTime.TryParse(stringDate, out DateTime date);
//date variable type is DateTime
Successful Sloth

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu