C# এ DateTime.ToLongTimeString() পদ্ধতিটি বর্তমান DateTime অবজেক্টের মানকে এর সমতুল্য দীর্ঘ সময়ের স্ট্রিং উপস্থাপনায় রূপান্তর করতে ব্যবহৃত হয়।
সিনট্যাক্স
নিম্নলিখিত বাক্য গঠন −
public string ToLongTimeString ();
উদাহরণ
এখন DateTime.ToLongTimeString() পদ্ধতি প্রয়োগ করার জন্য একটি উদাহরণ দেখা যাক -
using System;
using System.Globalization;
public class Demo {
public static void Main() {
DateTime d = DateTime.Now;
Console.WriteLine("Date = {0}", d);
Console.WriteLine("Current culture = "+CultureInfo.CurrentCulture.Name);
var pattern = CultureInfo.CurrentCulture.DateTimeFormat;
string str = d.ToLongTimeString();
Console.WriteLine("Long time string = {0}", pattern.LongTimePattern);
Console.WriteLine("Long time string representation = {0}", str);
}
} আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেDate = 10/16/2019 8:41:03 AM Current culture = en-US Long time string = h:mm:ss tt Long time string representation = 8:41:03 AM
উদাহরণ
এখন DateTime.ToLongTimeString() পদ্ধতি প্রয়োগ করার জন্য আরেকটি উদাহরণ দেখা যাক -
using System;
public class Demo {
public static void Main() {
DateTime d = new DateTime(2019, 11, 11, 7, 11, 25);
Console.WriteLine("Date = {0}", d);
string str = d.ToLongTimeString();
Console.WriteLine("Long time string representation = {0}", str);
}
} আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেDate = 11/11/2019 7:11:25 AM Long time string representation = 7:11:25 AM