@DateTime.Now is not working

ehsung 1 Reputation point

I finally displayed asp file in a browser (Chrome) but it shows 'The time is @DateTime.Now' not actual time (e.g. The time is 1/16/2022 04:09:25 PM). Can you please tell me how to display actual time? Please give me references if you have it

<!DOCTYPE html>
<h1>Hello Web Pages</h1>
<p>The time is @DateTime.Now</p>


A set of technologies in the .NET Framework for building web applications and XML web services.
3,241 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,061 Reputation points

    Hi @ehsung ,
    I think you need use <%=now%> instead of @DateTime.Now.Just like this:

    <h1>Hello Web Pages</h1>  
    <p>The time is <%= now%></p>  

    Best regards,
    Yijing Sun

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments