Dates

Dates in SalsaScript are normal Javascript Date Objects that can be saved to the database, read from the database, and manipulated and formatted.

Formatting a Date

Frequently you may need to format how a Javascript date is displayed to the screen. While you can use the standard Javascript .getDate(), .getYear() etc., Salsa also provides a convenient formatting method

salsa.formatDate(Date,format)

<?
var currentDate=new Date();

?>

Current Date=<?=salsa.formatDate(currentDate,"MMM dd, yyyy")?>
results in:


Current Date=May 06, 2024
The optional format string follows the same rules as the Java SimpleDateFormat class.