如何在文本字段中显示日期? [英] How Do I Display Date Inside Text Field?

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

问题描述

< html>

< body>

日期:< input type =textname =namevalue =>



echo今天是。日期(Y / m / d)。
;

?>



< / body>

< / html> ;

解决方案

它非常简单只需在输入文本框内回显它值



< pre lang =txt>< html>
< body>

日期:<输入类型=文本 = 今天是:<?php echo


date?> />
< / body >
< / html >


请参阅:

http://en.wikipedia.org/wiki/JavaScript [ ^ ],

https:/ /developer.mozilla.org/en-US/docs/Web/HTML/Element/script [ ^ ],

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/script [ ^ ],

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date [ ^ ]。



我没有提供HTML的任何链接,但认为阅读这个主题也可能对你有用。 :-)







以上,我在客户端的方式回答得到时间,后来才注意到标签PHP。 也许这是因为代码中没有PHP的痕迹。 [参见编辑#2]我不确定你理解PHP的用途。



其中一个想法是:PHP文件是带有一些PHP代码的HTML文件。 PHP的片段标有<?PHP ...?> ,表达式是PHP转到 HTTP响应地点。这样,HTML内容就会自动,全部或部分生成。输出所有HTML文本时生成完整内容,其中PHP echo 。在其他情况下,你只是逃避一些PHP片段。



参见:

http://php.net/manual/en/language.basic-syntax.php [ ^ ],

http://php.net/manual/en/book.datetime.php [ ^ ]。



看,来自你的问题,尤其是后续问题,我真的觉得时间不是你的问题。你真的需要了解Web的工作原理,客户端和服务器端的情况,HTTP协议的作用以及所有其他组件。







我没有在你的代码中看到PHP,但它就在那里。这是元问题,如果写一个问题就会出现问题。您的< php 根本没有显示,因为此页面是HTML页面,而HTML'<'需要转义为 &安培; LT; 。但他们,如果你正在进行Web开发,你认为你不应该掌握HTML,你至少可以用它在这个论坛上写问题,这是基本技能吗?你可以看到你的帖子的结果,并解决问题。



-SA


<html>
<body>
Date: <input type="text" name="name" value="">

echo "Today is " . date("Y/m/d") . "
";
?>

</body>
</html>

解决方案

its very simple just echo it inside the input text box value

<html>
<body>

Date:  <input type=text value="Today is: <?php   echo


date ?>" /> </body> </html>


Please see:
http://en.wikipedia.org/wiki/JavaScript[^],
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script[^],
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/script[^],
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date[^].

I did not provides any link to HTML, but feel that reading on this topic may also be useful for you. :-)

[EDIT #1]

Above, I answered on the client-side way of getting time, only later I noticed the tag "PHP". Perhaps this is because there is no trace of PHP in your code. [See EDIT #2] I'm not sure you understand what PHP does.

One of the ideas is: PHP file is the HTML file with some PHP code. The fragment of PHP is marked with <?PHP ... ?>, and the expression is PHP goes to HTTP response in the same location. This way, HTML content is generated automatically, fully or partly. Full content is generated when all the HTML text is output which PHP echo. In other cases, you just "escape" to some PHP fragments.

See also:
http://php.net/manual/en/language.basic-syntax.php[^],
http://php.net/manual/en/book.datetime.php[^].

Look, from your question, and especially follow-up questions, I really feel that not time is your problem. You really need to understand how Web works in general, what happens on client and server sides, the role of HTTP protocol and all other components.

[EDIT #2]

I did not see PHP in your code, but it was there. This is the "meta-problem", the problem if writing a question. Your <php simply wasn't displayed, because this page is the an HTML page, and in HTML '<' needs to be escaped as &lt;. But them, if you are doing Web development, don't you think you should master HTML to the degree you could at least use it for writing questions on this forum, which is the elementary skill? And you could just see the result of your post, and fix the problem.

—SA


这篇关于如何在文本字段中显示日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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