How to change date from dd/mm/yyyy to dd/MMM/yyyy and hh:mm to hh:mm tt?
The <%=time.START_TIME%> is from the database which is store as 24H
I got error in code. the error is CS0103: The name 'date' does not exist in the current context
Here is the code:
- <%
- if(obj.DATE.Substring(4, 2) == "01"){
- var date = obj.DATE.Substring(6, 2) + " Jan " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "02"){
- var date = obj.DATE.Substring(6, 2) + " Feb " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "03"){
- var date = obj.DATE.Substring(6, 2) + " Mar " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "04"){
- var date = obj.DATE.Substring(6, 2) + " Apr " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "05"){
- var date = obj.DATE.Substring(6, 2) + " May " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "06"){
- var date = obj.DATE.Substring(6, 2) + " June " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "07"){
- var date = obj.DATE.Substring(6, 2) + " July " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "08"){
- var date = obj.DATE.Substring(6, 2) + " Aug " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "09"){
- var date = obj.DATE.Substring(6, 2) + " Sept " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "10"){
- var date = obj.DATE.Substring(6, 2) + " Oct " + obj.DATE.Substring(0, 4);
- }
- else if (obj.DATE.Substring(4, 2) == "11"){
- var date = obj.DATE.Substring(6, 2) + " Nov " + obj.DATE.Substring(0, 4);
- }
- else{
- var date = obj.DATE.Substring(6, 2) + " Dec " + obj.DATE.Substring(0, 4);
- }
- %>
- <body>
- <tr>
- <td colspan="2" rowspan="2" bordercolor="#0066CC" style="border:2px solid #CCC; border-radius:20px; background:#CCC; font-family: tahoma;"><h2 align="center" style="font-family: sans-serif; font-size:calc(24px); padding:5px;">Your appointment is confirmed on:</h2>
- <h1 align="center"><strong style="font-family: tahoma; font-size:27px;"><%=date %> </strong> at <strong style="font-family:tahoma; font-size:27px;"><%=time.START_TIME%></strong></h1></td>
- </tr>
- </body>
Thanks