@DateTime.Now is not working

ehsung 1 Reputation point
2022-01-16T20:59:00.213+00:00

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>
<html>
<body>
<h1>Hello Web Pages</h1>
<p>The time is @DateTime.Now</p>
</body>
</html>

165410-asp.png

ASP.NET
ASP.NET
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
    2022-01-17T06:18:40.537+00:00

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

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

    Result:
    165539-capture16.png
    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