-1

The date time that passed from a classic ASP page is displayed at WebView as below. How can I change it to proper DD-MM-YYYY HH:MM:SS? Do i need to convert the date time to string at the classic ASP Page or I can do something at iOS to rectify this issue.

pic

Asp Classic

<%

   fpx_sellerTxnTime = request.Form("fpx_sellerTxnTime")

%>

<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SHARE FITNESS</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
    <div class="main">
        <!---728x90--->
        <h1>Payment Receipt</h1>
        <div class="content">
            <div class="sap_tabs">
                <div id="horizontalTab" style="display: block; width: 100%; margin: 0px;">
                    <div class="resp-tabs-container">
                        <h2 class="resp-accordion resp-tab-active" role="tab" aria-controls="tab_item-0"><span class="resp-arrow"></span>Credit Card</h2><div class="tab-1 resp-tab-content resp-tab-content-active" aria-labelledby="tab_item-0" style="display:block">
                            <div class="payment-info">
                                <form action="fpx_confirm.php" method="post">
                                    <div style="color:black;border: 1px solid black;" >
                                        <table style = "margin:5px;text-align:left;">
                                            <tr>
                                                <th style="text-align:right;">Date & Time :</th> <th>&nbsp <%=fpx_sellerTxnTime%></th>
                                            </tr>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>  
                </div>
            </div>  
        </div>
    </div>

</body>
</html>
Community
  • 1
  • 1
Hanz Cheah
  • 761
  • 5
  • 15
  • 44
  • I think you can run the javascript, that change your date `string` to the `date format` you want. – Quoc Nguyen Apr 16 '18 at 04:54
  • can you share code where you saved date and time please? –  Apr 16 '18 at 04:59
  • store/save date like upper formate which you want. –  Apr 16 '18 at 05:16
  • Is it that I have to format the data at ASP Classic page. – Hanz Cheah Apr 16 '18 at 06:33
  • Possible duplicate of [Format current date and time](https://stackoverflow.com/questions/22574092/format-current-date-and-time) – user692942 Apr 16 '18 at 07:14
  • The `fpx_sellerTxnTime` is being populated from a form POST. Please show how the form value is populated before it is submitted. – user692942 Apr 16 '18 at 07:18
  • If I response.write `fpx_sellerTxnTime` at the ASP Classic page, I will get 20180416122649 – Hanz Cheah Apr 17 '18 at 02:03
  • @HansheungCheah already know this as it’s shown in the screenshot of your app. What i’m asking is how is the value generated before it is posted to the ASP page, what generates `20180416122649`, JavaScript, manual input or what? – user692942 Apr 18 '18 at 07:49
  • Oh well, I cannot find out because it is generated by a 3rd party payment gateway. I assume it will be Javascript but anyway, I will format the string. – Hanz Cheah Apr 18 '18 at 07:53

1 Answers1

2

Something like this should do the job.

<%
Dim date_string: date_string = "20180416122649"
Response.Write ParseStringDate(date_string)

Function ParseStringDate(value)
  Dim dt(5)
  Dim fmt: fmt = Array(4, 2, 2, 2, 2, 2)
  Dim pos: pos = 1
  Dim i, s
  If Len(value & "") > 0 Then
    For i = 0 To UBound(dt)
      s = Mid(value, pos, fmt(i))
      If Len(s) > 0 And IsNumeric(s) And i < 3 Then dt(i) = CInt(s) Else dt(i) = s
      pos = pos + fmt(i)
    Next

    value = CDate(DateSerial(dt(0), dt(1), dt(2)) & " " & TimeValue(dt(3) & ":" & dt(4) & ":" & dt(5)))
  End If
  ParseStringDate = value
End Function
%>

Output:

16/04/2018 12:26:49
user692942
  • 16,398
  • 7
  • 76
  • 175