General Date Short Time ফরম্যাট স্পেসিফায়ার শর্ট ডেট ("d") এবং শর্ট টাইম ("t") প্যাটার্নের সংমিশ্রণ, যা একটি স্পেস দ্বারা পৃথক।
DateTime ব্যবহার করে একটি ডেট সেট করুন।
DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20);
এখন, ("g") ফরম্যাট স্পেসিফায়ার ব্যবহার করুন।
dt.ToString("g", DateTimeFormatInfo.InvariantInfo));
উদাহরণ
using System; using System.Globalization; class Demo { static void Main() { DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20); Console.WriteLine(dt.ToString("g", DateTimeFormatInfo.InvariantInfo)); Console.WriteLine(dt.ToString("g", CultureInfo.CreateSpecificCulture("en-us"))); } }
আউটপুট
10/02/2018 07:59 10/2/2018 7:59 AM