Here is complete code example of How to format Date in Java using SimpleDateFormat. In this example we will see simple date formatting without time information e.g. dd-MM-yyyy, Date formatting with time information with patterns like dd-MM-yyyy:HH:mm:SS and Dates with timezone...
Предпочтительный формат. YYYY-MM-DD hh:mm:ss. Пример
& convert(varchar(24),'dd/mm/yyyy hh:mm:ss',121). both gives me that error- The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Format date in mm-dd-yyyy hh:mm:ss format. 52. Format year in yy format like 07, 08 etc.
var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss")
string dateTime = DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss"); EDIT: I just noticed you want to show AM/PM as well, you can show that if you add "tt" in your format string