Format JS And Convert Format Date C#
Format JS
var m = new Date();
var dateString = m.getUTCFullYear() +"/"+ (m.getUTCMonth()+1) +"/"+ m.getUTCDate() + " " + m.getUTCHours() + ":" + m.getUTCMinutes() + ":" + m.getUTCSeconds();
other sample :
var approvedDate = "";
var approvedDateCon = new Date(getData.ApprovedDate);
getData.ApprovedDate == null ? approvedDate = "-" : approvedDate = approvedDateCon.getDate().toString().padStart(2, 0) + `-` + (approvedDateCon.getUTCMonth()+1).toString().padStart(2, 0) + `-` + approvedDateCon.getFullYear() + ` ` + approvedDateCon.getHours().toString().padStart(2, 0) + `:` + approvedDateCon.getMinutes().toString().padStart(2, 0);
// searchDate = "24 May 2022 - 24 May 2022'"
string[] s = searchDate.Split('-');
DateTime dt1 = DateTime.Parse(s[0].Trim());
DateTime dt2 = DateTime.Parse(s[1].Trim());
dt2 = dt2.AddDays(1);
//DateTime dt1 = DateTime.Parse(searchDate);
//DateTime dt2 = dt1.AddDays(1);
query = query.Where(x => x.ApplyDate >= dt1 && x.ApplyDate < dt2);
====================================
// Online C# Editor for free
// Write, Edit and Run your C# code using C# Online Compiler
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
var tgl = "03 May 2022 - 07 May 2022";
string[] s = tgl.Split('-');
Console.WriteLine (s[0].Trim());
Console.WriteLine (s[1].Trim());
}
}
Tidak ada komentar