|
|
|
กำหนด formatDatetime ยังไงคับ ต้องการเปลี่ยน formatdatetime จากเดิม 27/7/2548 08:00 เป็น 2005-07-27 |
|
|
|
|
|
|
|
อ้อ...ถ้าอยากได้แบบนั้นนะครับ function formatdatetime ไม่สามารถทำให้ได้นะครับ จะต้องทำด้วยตนเองโดยวิธีการตัดสตริงแล้วก็นำสตริงมาต่อกันนะครับ
|
|
|
|
|
Date :
27 ก.ค. 2548 12:04:54 |
By :
นายกระจอก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้ากำหนดแบบนั้น ผมทำ function ใช้เองครับ Code ก็ประมาณนี้ การใช้งานเหมือนใน VB
=======================================================================
<%
Function FormatDate(iDate,Style)
' Year Section
' Example: iDate = "1/01/2005"
' ==========================================================
' YYYY = 2005
' YY = 05
' ==========================================================
If Year(iDate) < 1900 Then
Style = Replace(Style,"YYYY",Year(iDate)+543)
Style = Replace(Style,"YY",Right(Year(iDate)+543,2))
Else
Style = Replace(Style,"YYYY",Year(iDate))
Style = Replace(Style,"YY",Right(Year(iDate),2))
End if
' Month Section
' Example: iDate = "1/01/2005"
' ==========================================================
' MMMM = January
' MMM = Jan
' MM = 01
' M = 1
' ==========================================================
Style = Replace(Style,"MMMM",MonthName(Month(iDate)))
Style = Replace(Style,"MMM",MonthName(Month(iDate),True))
Style = Replace(Style,"MM",Right("00" & Month(iDate),2))
Style = Replace(Style,"M",Month(iDate))
' Day Section
' Example: iDate = "1/01/2005"
' ==========================================================
' DDDD = Friday
' DDD = Fri
' DD = 01
' D = 1
' ==========================================================
Style = Replace(Style,"DDDD",WeekDayName(WeekDay(iDate)))
Style = Replace(Style,"DDD",WeekDayName(WeekDay(iDate),True))
Style = Replace(Style,"DD",Right("00" & Day(iDate),2))
Style = Replace(Style,"D",Day(iDate))
Style = Replace(Style,"hh",Right("00" & Hour(iDate),2))
Style = Replace(Style,"h",Hour(iDate))
Style = Replace(Style,"mm",Right("00" & Minute(iDate),2))
Style = Replace(Style,"m",Minute(iDate))
Style = Replace(Style,"ss",Right("00" & Second(iDate),2))
Style = Replace(Style,"s",Second(iDate))
FormatDate = Style
End Function
Response.Write FormatDate(Now(),"YYYY-MM-DD hh:mm:ss") & "<br>"
Response.Write FormatDate(Now(),"DDDD MMMM YYYY hh:mm:ss")
%>
|
|
|
|
|
Date :
27 ก.ค. 2548 15:37:35 |
By :
JezusMitsui |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|