日期问题 [英] Date Question

查看:77
本文介绍了日期问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在解决一个问题并急需帮助!


我需要提示用户出生的数月,出生日和

出生年份并将其存储在varialbes中并使用变量构建一个

日期对象。然后以完整的形式打印生成的日期对象。在

屏幕上使用document.write。这是为学校而且我认为我开始是正确的,但似乎无法理解我做错了什么,或者

从哪里开始。任何提示都将不胜感激。


这是我到目前为止的...


< script>

var mob = prompt(你的出生月份,数字?,04);

var dob = prompt("你的出生日期是什么时候) ,数字?,07);

var yob = prompt(你出生的年份是什么,数字?,1967);

month.setMonth(mob-1);

day.setDate(dob);

year.setFullYear(yob);

document.write(" Your birthday is" + date +"< br>");

< / script>

KL

解决方案

KL说:


我正在解决一个问题并迫切需要帮助!
日期对象。然后以完整的形式打印生成的日期对象。在屏幕上使用document.write。这是为了学校,我认为我开始正确,但似乎无法理解我做错了什么,或者从这里去哪里。任何提示都将不胜感激。

这是我到目前为止...

< script>
var mob = prompt("什么是您的出生月份,数字?,04);
var dob =提示(您的出生日期,数字?,07);
var yob = prompt(你的出生年份,数字?,1967);
month.setMonth(mob-1);
day.setDate(dob);
year.setFullYear(yob);
document.write(" Your birthday is" + date +"< br>");
< / script>




您希望拥有一个日期对象,而不是每个月,日和年各一个。

最简单的方法是使用Date()构造函数的形式,

将月,日和年作为参数。


var date = new Date(...为你留下找...或询问......);

document.write(...就像你拥有它一样......);


"乐E" < RE ************** @ cox.net>在消息中写道

news:co ********* @ drn.newsguy.com ...

KL说:


我正在解决一个问题并迫切需要帮助!

我需要提示用户出生数月,出生日和出生年份和存储年份它在变量和使用变量构建
日期对象。然后以完整的形式打印生成的日期对象。在屏幕上使用document.write。这是为学校而且我认为我开始正确,但似乎无法理解我做错了什么,

从哪里开始。任何提示都将不胜感激。

这是我到目前为止...

< script>
var mob = prompt("什么是您的出生月份,数字?,04);
var dob =提示(您的出生日期,数字?,07);
var yob = prompt(你的出生年份,数字?,1967);
month.setMonth(mob-1);
day.setDate(dob);
year.setFullYear(yob);
document.write(" Your birthday is" + date +"< br>");
< / script>



你想拥有一个日期对象,而不是一个月,日和
年。
最简单的方法是使用的形式Date()构造函数
将月,日和年作为参数。

var date = new Date(...留给你找...或者询问一下...);
document.write(...就像你拥有它...);




好​​的我已阅读并重读此内容我想我得到了一些。但是我对于什么是Date()构造函数感到困惑。我不认为我们在课堂上报道了这个

我在书中找不到它......或者我看起来不对..我会

再看一下,但与此同时,有人能告诉我什么日期()

构造函数?


KL


KL写道:

[...]

好的我已经阅读并重读了这个,我想我得到了一些。但我对Date()构造函数的含义感到困惑。我不认为我们在课堂上报道了这个,我在书中找不到它......或者我看起来不对..我会再看一遍,但是与此同时,有人可以告诉我什么日期()
构造函数?




请尝试以下方法:


< script type =" text / javascript">

var mob = prompt("你的出生月份,数字?,04);

var dob = prompt(你的出生日期,数字?,07);

var yob = prompt("年份是多少年)你的出生,数字?,,1967年);


var bDay =新日期(yob,mob,dob);

alert( bDay);

< / script>

-

Rob


I am working on a problem and desperately need help!

I need to prompt a user for the numerical month of birth, day of birth and
year of birth and store it in varialbes and the use the variables to build a
date object. Then print the resulting date object, in it''s full form. on
the screen using document.write. This IS for school and I think I am
starting out right, but can''t quite seem to grasp what I am doing wrong, or
where to go from here. Any tips would be greatly appreciated.

Here is what I have so far...

<script>
var mob=prompt("What is your month of birth, numerically?", "04");
var dob=prompt("What is the date of your birth, numerically?", "07");
var yob=prompt("What is the year of your birth, numerically?", "1967");
month.setMonth(mob-1);
day.setDate(dob);
year.setFullYear(yob);
document.write("Your birthday is " + date + "<br>");
</script>
KL

解决方案

KL said:


I am working on a problem and desperately need help!

I need to prompt a user for the numerical month of birth, day of birth and
year of birth and store it in varialbes and the use the variables to build a
date object. Then print the resulting date object, in it''s full form. on
the screen using document.write. This IS for school and I think I am
starting out right, but can''t quite seem to grasp what I am doing wrong, or
where to go from here. Any tips would be greatly appreciated.

Here is what I have so far...

<script>
var mob=prompt("What is your month of birth, numerically?", "04");
var dob=prompt("What is the date of your birth, numerically?", "07");
var yob=prompt("What is the year of your birth, numerically?", "1967");
month.setMonth(mob-1);
day.setDate(dob);
year.setFullYear(yob);
document.write("Your birthday is " + date + "<br>");
</script>



You want to have a single date object, not one each for month, day and year.
The easiest way to do that is to use the form of the Date() constructor that
takes month, day and year as arguments.

var date=new Date(...left for you to find...or ask about...);
document.write(...as you have it...);


"Lee" <RE**************@cox.net> wrote in message
news:co*********@drn.newsguy.com...

KL said:


I am working on a problem and desperately need help!

I need to prompt a user for the numerical month of birth, day of birth and
year of birth and store it in varialbes and the use the variables to build
a
date object. Then print the resulting date object, in it''s full form. on
the screen using document.write. This IS for school and I think I am
starting out right, but can''t quite seem to grasp what I am doing wrong,
or
where to go from here. Any tips would be greatly appreciated.

Here is what I have so far...

<script>
var mob=prompt("What is your month of birth, numerically?", "04");
var dob=prompt("What is the date of your birth, numerically?", "07");
var yob=prompt("What is the year of your birth, numerically?", "1967");
month.setMonth(mob-1);
day.setDate(dob);
year.setFullYear(yob);
document.write("Your birthday is " + date + "<br>");
</script>



You want to have a single date object, not one each for month, day and
year.
The easiest way to do that is to use the form of the Date() constructor
that
takes month, day and year as arguments.

var date=new Date(...left for you to find...or ask about...);
document.write(...as you have it...);



OK I have read and reread this and I think I get some of it. But I am
confused as to what a Date() Constructor is. I don''t think we covered that
in class and I don''t find it in my book...or I didn''t look right..I will
look again, but in the meantime, what can someone tell me about the Date()
Constructor?

KL


KL wrote:
[...]

OK I have read and reread this and I think I get some of it. But I am
confused as to what a Date() Constructor is. I don''t think we covered that
in class and I don''t find it in my book...or I didn''t look right..I will
look again, but in the meantime, what can someone tell me about the Date()
Constructor?



Try the following:

<script type="text/javascript">
var mob=prompt("What is your month of birth, numerically?","04");
var dob=prompt("What is the date of your birth, numerically?","07");
var yob=prompt("What is the year of your birth, numerically?","1967");

var bDay= new Date(yob,mob,dob);
alert(bDay);
</script>
--
Rob


这篇关于日期问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆