Ciao....
Su ASP ho sempre usato questa funzione:
codice:
function dateToString(theDate)
sessionLCID = session.LCID
if not sessionLCID = 1040 then
session.LCID = 1040
end if
'if not isDate(theDate) then
' theDate = now()
'end if
theYear = datePart("yyyy",theDate)
theMonth = datePart("m",theDate)
if theMonth < 10 then theMonth = "0" & theMonth
theDay = datePart("d",theDate)
if theDay < 10 then theDay = "0" & theDay
theHour = datePart("h",theDate)
if theHour < 10 then theHour = "0" & theHour
theMinutes = datePart("n",theDate)
if theMinutes < 10 then theMinutes = "0" & theMinutes
theSeconds = datePart("s",theDate)
if theSeconds < 10 then theSeconds = "0" & theSeconds
dateToString = theYear & theMonth & theDay & theHour & theMinutes & theSeconds
session.LCID = sessionLCID
end function
function stringToDate(theString)
if len(theString) = 14 then
theYear = left(theString,4)
theMonth = mid(theString,5,2)
theDay = mid(theString,7,2)
theHour = mid(theString,9,2)
theMinutes = mid(theString,11,2)
theSeconds = right(theString,2)
if session.LCID = 1040 then
stringToDate = theDay & "/" & theMonth & "/" & theYear
theChar = "."
else
stringToDate = cInt(theMonth) & "/" & cInt(theDay) & "/" & theYear
theChar = ":"
end if
stringToDate = cDate(stringToDate & " " & theHour & theChar & theMinutes & theChar & theSeconds)
else
stringToDate = now()
end if
end function
In soldoni, impostato il SessionLCID in italico, trasforma data e ora in un bel 20100603191221
E poi si può risplittare al contrario...
Il vantaggio è evidente!
Ora... prima che mi ci metto e la riscrivo in PHPese (
) non è che esiste qualcosa di già fatto da altri? Ho googlato per un po' ma non ho trovato molto... anzi.. niente....
grazie!