FormatDateTimeCustom
Definition
- Namespace
- Resto.Front.PrintTemplates.Cheques.Razor
Formats a date/time using a standard or custom .NET format string.
string TemplateBase<T>.FormatDateTimeCustom(DateTime dateTime, string format)
- Returns
string- Nullability
- Not specified
- Declared in
- Resto.Front.PrintTemplates.Cheques.Razor.TemplateBase<T>
- Model purpose
- Base class for Legacy Razor print templates. Model contains the document data of type T. Provides formatting and markup output methods.
Parameters
DateTime dateTime- Date/time value to format.
string format- A .NET date/time format. Null or an empty string selects the general G format.
Return value
The result of dateTime.ToString(format) in CurrentCulture.
Remarks
Standard format specifiers and custom literals follow DateTime.ToString semantics. Quote literal text; use HH for 24-hour time, MM for month and mm for minutes. Standard formats such as U can convert time according to .NET rules.
Exceptions
System.FormatException- format contains an invalid standard specifier or an invalid custom pattern.
System.ArgumentOutOfRangeException- The current calendar cannot represent the supplied value.
Example
FormatDateTimeCustom(new DateTime(2026, 9, 19, 14, 35, 42), "yyyy-MM-dd"); // Gregorian calendar: "2026-09-19"