By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,044 Members | 1,377 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,044 IT Pros & Developers. It's quick & easy.

Work out Yesterdays date

P: n/a
Hi,

Does anyone know where i can get some javscript code to work out yesterdays
date

Thanks
Mark
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Mark wrote on 20 feb 2005 in comp.lang.javascript:
Does anyone know where i can get some javscript code to work out
yesterdays date


<script type='text/javascript'>
var D = new Date()
with (D) setDate(getDate()-1)
alert(D)
</script>

From:
<http://www.merlyn.demon.co.uk/js-date1.htm#incr>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

P: n/a
Mark wrote:
Hi,

Does anyone know where i can get some javscript code to work out yesterdays
date


d=new Date().getDate()
d.setDate(d-1)

Mick
Jul 23 '05 #3

P: n/a
Mick White wrote:
Mark wrote:
Hi,

Does anyone know where i can get some javscript code to work out
yesterdays date


d=new Date().getDate()
d.setDate(d-1)

Mick

sorry
d=new Date()
dt=d.getDate();
d.setDate(dt-1)

Mick
Jul 23 '05 #4

P: n/a
Mick White wrote:
Mick White wrote:
Mark wrote:
Hi,

Does anyone know where i can get some javscript code to work out
yesterdays date
[...]
sorry
d=new Date()
dt=d.getDate();
d.setDate(dt-1)

Mick


Supposing, of course, that d is actually a date object that
represents 'today' as opposed to whatever date the users' PC has
been configured to think it is.

--
Zif
Jul 23 '05 #5

P: n/a
Zifud wrote:
yesterdays date

d=new Date()
dt=d.getDate();
d.setDate(dt-1)

Mick

Supposing, of course, that d is actually a date object that
represents 'today' as opposed to whatever date the users' PC has
been configured to think it is.


True, Zif, I should have issued the usual caveats.
Mick
Jul 23 '05 #6

P: n/a
Mick White wrote:

True, Zif, I should have issued the usual caveats.
Mick


Just thought I'd steal JRS's thunder. ;-)

--
Zif
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.