formatting date/time correctly for If-Modified-Since during AJAX call

C

Cartoper

How does one go about formatting the date/time string correctly to set
the If-Modified-Since to the current date/time in an AJAX call? I
know I need something like this:

request.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006
00:00:00 GMT');

But I don't know how to actually format the date/time string.
 
G

GArlington

How does one go about formatting the date/time string correctly to set
the If-Modified-Since to the current date/time in an AJAX call? I
know I need something like this:

request.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006
00:00:00 GMT');

But I don't know how to actually format the date/time string.

Why do you need to check it against current date/time? It will ALWAYS
return 304...
But, you might want to look at dateObj.toUTCString()
 
H

Henry

Why do you need to check it against current date/time? It will ALWAYS
return 304...
But, you might want to look at dateObj.toUTCString()

RFC 2616 mandates the date format to be used within HTTP 1.1 and so
with all relevant HTTP headers. No specification asserts that the -
toUTCStirng - method of javascript Date objects should have any
particular format. So the output of the - toUTCString - method may or
may not correspond with the HTTP spec's requirement, will very likely
vary between script language implementations and be subject to "more
tolerant" HTTP software. The result may work by coincidence in some
contexts (and from some specific locations) but is extremely unlikely
to be reliable or portable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top