?
Solved

Formatting ASP date yyyy-mm-dd hh:mm:ss

Posted on 2009-04-28
3
Medium Priority
?
2,333 Views
Last Modified: 2012-05-06
Hi
I need my date formatted like:
yyyy-mm-dd hh:mm:ss
Is there a function for this?

Thanks!
0
Comment
Question by:JuniorBee
  • 2
3 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 24251095
Yes, check documentation for the .ToString method of the DateTime object.

DateTime dt = DateTime.Now;
Response.Write(dt.ToString("yyyy-MM-dd HH:mm:ss"));

Dim dt As DateTime = DateTime.Now
Response.Write(dt.ToString("yyyy-MM-dd HH:mm:ss"))
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 2000 total points
ID: 24251124
Sorry...assumed ASP.Net.

Using VBScript with older ASP you would need to use the Year(), Day(), Month(), etc. functions to get the pieces of a Time variable.

Dim currentTime

currentTime = Now
Response.Write Year(currentTime) & "-" & Month(currenTime) & "-" & Day(currentTime) . . . etc.
0
 

Expert Comment

by:roblickley
ID: 24255200
How will the date and time be presented to the function.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question