?o?n Code sau ?�y gi�p ch�ng ta th�m s? 0 v�o tr??c c�c ng�y(th�ng) 1 ??n 9 ?? chuy?n ch�ng th�nh 01-09.
S? d?ng h�m Day(Date) Month(Date) ?? l?y ng�y, th�ng v� h�m Len ?? so s�nh ?? d�i c?a chu?i ng�y th�ng.
?? l?y ng�y v� th�ng tr??c h?t ch�ng ta khai b�o 2 bi?n chu?i sau:
Dim strDay, strMonth
N?u chu?i gi� tr? c?a strDay = 1 (k� t?) t?c ng�y 1-9(ng�y n�y ch? 1 k� t? 1,2,3...) th� ch�ng ta th�m s? 0 v�o tr??c:
If Len(Day(Date) = 1 Then 'N?u chu?i Day(Date) ch? c� 1 character th�:
strDay = "0" & Day(Date) 'Th�m s? 0 v�o tr??c chu?i ?�
Else 'C�n l?i th�
strDay = Day(Date) 'strDay = gi� tr? c?a ng�y.
End If
L�m t??ng t? v?i h�m Month(Date)
?�y l� Source codes ??y ?? c?a h�m 3 h�m Day(Date), Month(Date) v� Year(Date)
<%
Dim strDay, strMonth, strYear
strDay = Day(Date)
strMonth = Month(Date)
If Len(Day(Date)) = 1 Then
strDay = "0" & Day(Date)
Else
strDay = Day(Date)
End If
If Len(Month(Date)) = 1 Then
strMonth = "0" & Month(Date)
Else
strMonth = Month(Date)
End If
strYear = Year(Date)
%>
L?y k?t qu?:
<% = strDay %>/<%= strMonth %>/<% = strYear %>
Đăng nhận xét