User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 332,778 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,830 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Sep 20th, 2004
Views: 4,455
Learn how to take the Now() command and format it in a bunch of differnt ways.

Code from: http://www.iportalx.net
Last edited : Jan 2nd, 2007.
asp Syntax | 4 stars
  1. <%= Date() %>
  2. Produces: 07/01/2002
  3.  
  4. <%= Now() %>
  5. Produces: 07/01/2002 3:47:42 PM
  6.  
  7. <%= Time() %>
  8. Produces: 3:47:42 PM
  9.  
  10. <%= FormatDateTime(strDate, 0) %>
  11. Produces: 07/01/2002 3:47:42 PM
  12.  
  13. <%= FormatDateTime(strDate, 1) %>
  14. Produces: Monday, July 01, 2002
  15.  
  16. <%= FormatDateTime(strDate, 2) %>
  17. Produces: 07/01/2002
  18.  
  19. <%= FormatDateTime(strDate, 3) %>
  20. Produces: 3:47:42 PM
  21.  
  22. <%= FormatDateTime(strDate, 4) %>
  23. Produces: 15:47
  24.  
  25. <%= Year(strDate) %>
  26. Produces: 2002
  27.  
  28. <%= Month(strDate) %>
  29. Produces: 7
  30.  
  31. <%= MonthName(Month(strDate)) %>
  32. Produces: July
  33.  
  34. <%= MonthName(Month(strDate), 1) %>
  35. Produces: Jul
  36.  
  37. <%= Day(strDate) %>
  38. Produces: 1
  39.  
  40. <%= WeekDay(strDate) %>
  41. Produces: 2
  42.  
  43. <%= WeekDayName(WeekDay(strDate)) %>
  44. Produces: Monday
  45.  
  46. <%= WeekDayName(WeekDay(strDate), 1) %>
  47. Produces: Mon
  48.  
  49. <%= Minute(strDate) %>
  50. Produces: 47
  51.  
  52. <%= Second(strDate) %>
  53. Produces: 42
  54.  
  55. <%= DateAdd("d", 1, strDate) %>
  56. Produces: 07/02/2002 3:47:42 PM
  57.  
  58. <%= DateAdd("d", -1, strDate) %>
  59. Produces: 06/30/2002 3:47:42 PM
  60.  
  61. <%= DateDiff("d", "1/1/2000", strDate) %>
  62. Produces: 912
  63.  
  64. <%= Day(strDate) & "/" & Month(strDate) & "/" & Year(strDate) %>
  65. Produces: 1/7/2002
  66.  
  67. <%= WeekDayName(WeekDay(strDate)) & ", " & Day(strDate) & " " & MonthName(Month(strDate)) & ", " & Year(strDate) %>
  68. Produces: Monday, 1 July, 2002
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 9:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC