• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 661
  • Last Modified:

ASP "Get Date" from Browser Code

How can I format the text of this asp script to specify script & other text properties.

<%
          curdate = Now
          If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
          response.write pDate
      %>
0
technick
Asked:
technick
1 Solution
 
IeuanJCommented:
do you mean format the output text ?  you can do this by including html tags in the output as follows.

<%
         curdate = Now
         If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
         response.write ("<FONT COLOR=""RED"">" & pDate & "<FONT>")
%>

If this isnt what you mean then please explain further.
0
 
technickAuthor Commented:
So I could do it like this?

<%
        curdate = Now
        If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
        response.write ("<FONT COLOR=""WHITE"">" & pDate & "<NEW TIMES ROMAN>")
%>
0
 
NicolNghiaCommented:
Hi technick,

No, you can do as below:

<%
       curdate = Now
       If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
       response.write ("<FONT style="BACKGROUND-COLOR: lightgoldenrodyellow" color=mediumvioletred>  face='Lucida Console'" & pDate & "</FONT>")'Replace 'Lucida Console' with the font you want
%>


Note that, in case you use 'Times New Roman', you don't need to specify the 'face' attribute, because this is default font name. And the code as below:

       response.write ("<FONT style="BACKGROUND-COLOR: lightgoldenrodyellow" color=mediumvioletred>" & pDate & "</FONT>")


good luck,
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JigitCommented:
Unfortunately, this
  response.write ("<FONT style="BACKGROUND-COLOR: lightgoldenrodyellow" color=mediumvioletred>" & pDate & "</FONT>")

won't work. You cannot put " inside a string in this way. You can put them twice or replace them with ', as shown below:

  Response.Write ("<FONT style=""BACKGROUND-COLOR: lightgoldenrodyellow"" color=mediumvioletred>" & pDate & "</FONT>")

OR

  Response.Write ("<FONT style='BACKGROUND-COLOR: lightgoldenrodyellow' color=mediumvioletred>" & pDate & "</FONT>")

HTH,
Jigit
0
 
IeuanJCommented:
here is the syntax for what you asked to do.

<%
       curdate = Now
       If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
       response.write ("<FONT COLOR=""WHITE"" FACE=""TIMES NEW ROMAN"">" & pDate</FONT>")
%>
0
 
IeuanJCommented:
here is the syntax for what you asked to do.

<%
       curdate = Now
       If IsDate(curdate) Then pDate = FormatDateTime(curDate, 1)
       response.write ("<FONT COLOR=""WHITE"" FACE=""TIMES NEW ROMAN"">" & pDate & "</FONT>")
%>
0
 
GhostModCommented:
PAQed - no points refunded (of 100)

GhostMod
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now