Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
日付を dd/mm/yy hh:mm の形式で表示したい
HrCreatedDate = DateTime.ParseExact(objMessagePoco.CreatedDate.ToString(), "dd/mm/yyyy hh:mm", CultureInfo.InvariantCulture);
しかし、それは私にエラーを与えています:
文字列は有効な DateTime として認識されませんでした。
何故ですか?
DateTime.ParseExact文字列を DateTime に解析します。既存の DateTime を文字列としてフォーマットするだけの場合は、そのフォーマットを に渡しますToString。
DateTime.ParseExact
ToString
var myStr = objMessagePoco.CreatedDate.ToString("dd/MM/yy HH:mm");