transform a date object to specfic text code example

Example 1: excel date to string conversion

'Excel formula to turn a date/time into text:

=TEXT(A1,"DD/MM/YYYY hh:mm:ss AM/PM")

'Reference:
'  https://support.office.com/en-us/article/text-function-20d5ac4d-7b94-49fd-bb38-93d29371225c

'---------------------------------------------------------------------------------------------

'VBA function to do the same thing:
Function DateToText$(dbl#)
    DateToText = Format(dbl, "DD/MM/YYYY hh:mm:ss AM/PM")
End Function

Example 2: js string to date

var myDate = new Date("2013/1/16");

var str = "2013/1/16";
var strToDate = new Date(str);

Tags:

Java Example