アクセスデータベースの日付と時刻の型フィールドに保存されている日付の場合、データベースからデータを直接読み取る効果は非常に時間がかかります。 Error New Technologyチャネルの編集者は、ASPの一般的に使用される日付フォーマット関数フォーマットについて詳しく説明します。
コアコード
<% '関数:多機能日付フォーマット機能'ソース:http://jorkin.reallydo.com/article.asp?id=477機能formatdate(sdateTime、sreallydo)dim sjorkin sjorkin = getlocale() CDATE(SDATETIME)SELECT CASE UCASE(SREALLYDO& "")CASE "0"、 "1"、 "2" 3 "、" 4 "formatdate = formatdateTime(sdateTime、sreallydo)case" 00 "formatdate = formatime(sdateTime(sdateTime) formatdate = formatdate(sdatetime、 "yyyyyy mm month dd date")case "02" formatdate(sdatetime、 "yyyy-mm-dd")case "03" formatdate = formatdate(sdatetime(sdatetime、 "hh:ss" ss "" 04 "formatedate") 「HH:MM」)ケース「ISO8601」、「Google」、「SiteMap "'// ISO8601形式、一般的にGoogleSitemapに使用される形式」、" +08:00 "はタイムゾーンです。 formatdate = formatdate(sdatetime、 "yyyy-mm-ddthh:mm:ss.000+08:00")case "rfc822"、 "rss"、 "feed" '// rfc822形式、一般的にrssに使用される "+0800"は時間帯です。 setLocale( "en-gb")formatdate = formatdate(sdatetime、 "ew、dd emm yyyy hh:mm:ss +0800")setlocale(sjorkin)case "rnd"、 "randizize" '// sjorkin = rnd(sjorkin = rnd) "yyymmddhhmmss")&_ fix((9 * 10^6 -1) * sjorkin) + 10^6ケースelse formatdate = sreallydo formatdate = formatdate( "yyyy"、yeyy "、sdateTime)formatdate = filmatdate(dd" "&dd" =置換(formatdate、 "hh"、right( "0"&hour(sdatetime)、2))formatdate = formatdate(formatdate、 "mm"、right( "0"&minute(sdateTime)、2))formatdate = cheplage(formatdate、 "ss"、righ right(year(sdatetime)、2))formatdate(formatdate、 "d"、sdatetime))formatdate = formatdate(formatdate、 "h"、hour(sdatetime))formatdate = formatdate、 "m"、minute(sdateTime))) Instr(1、formatdate、 "ew"、1)> 0 then setlocale( "en-gb")formatdate = formatdate(formatdate、 "ew"、ucase(weekday(sdatetime)、false))formatdate = formatdate = cheplage(formatdate、 "ew"、filmatdate)、form(s dateTime)、form、form) "ew"、ucase(weekdayname(weekday(sdatetime)、true)))))formatdate(formatdate、 "ew"、weekday(sdatetime)、true))setlocale(sjorkin)else formatdate = formatdate(formatdate、 "w"、weekday(sdatetimatedate)、form(sdatetet)、fals交換(formatdate、 "w"、weekdayname(sdatetime、true))の場合(1、formatdate、 "emm"、1)> 0の場合はend setlocale( "en-gb")formatdate =置き換え(formatdate、 "emm"、 "monthname(sdateTeTeTeTeTETIME)、fals = faltdate = emmatdate( MonthName(Month(Sdatetime)、true))setlocale(sjorkin)else formatdate(formatdate、 "mm"、right( "0"&month(sdatetime)、2))formatdate = formatdate(formatdate、 "m"、month(sdatetime))endの場合
使用法は次のとおりです。
<% 'ISO8601のフォーマット日付response.write(formatdate( "2008-03-06 08:03:06"、 "sitemap")' format on rfc822 format response.write(formatdate( "2008-03-06 08:03:06"、 "rs")、 "rs") year)respons.write(formatdate(now()、 "ew、emm/dd/yyyy")) '年、月、1日、時間、時間、秒のResponse.write(formatdate(now()、 "rnd"))
上記は、間違った新しいテクノロジーチャネルの編集者です。 ASPの一般的に使用される日付フォーマット関数フォーマットに関するコンテンツ。誰かがこの業界に興味を持っている場合、彼はこの点でトレーニングを提供できます。