Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Pro Code Clinic
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2004, 08:15 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default XP System Date Setting in relation to now() functi

Hello

This is something that has bugged me for a while now. I am Running XP Pro(SP1) and IIS 5.1 (SP1) in Australia GMT +10 TZ

Q1..Why does the now() function 'always' show mm/dd/yyy when?:

A.. my regional settings (control panel/regional settings and language option) are set to dd/mm/yyy (Aussie and my preferred format)

And

B.. My (Date and Time Properties / Time Zone) is set to Aussie Sydney....GMT +10

I am aware, and are familiar with the many date/time formatting VBScript functions, however:

Q2..Isnt the point of having the ability to change system formats to do just this (the now function gets it's values from the system clock - therefore it should reflect it)?

No matter what I do to my system (bear in mind I am a designer/coder not a system/network guy) I always have to run function to tweak dates

Q3..Am I missing something in IIS? my research tells me no, I’m sure the p2p techo’s can clear this up

Thank you in advance

Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old August 26th, 2004, 04:17 AM
Authorized User
 
Join Date: Dec 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt

I faced the same problem while designing an ASP page.

I am not sure my answer may match the requirement u need,
But i can explain u what i did to get the Date in dd/mm/yyyy format.

Now() returns always in mm/dd/yyyy format. (Standard format)
The same thing is followed in MS SQL server also.
Regional setting won't bother NOW() IMHO.

if u want to acheive the task of formatting the date in dd/mm/yyyy.
Then the below said may help you.

1. Build a Activex DLL in VB6.0 that formats the date and returns in the desired
   format you need.
                                    OR

2. Write a function in ASP which interchanges the position of Month <-> Day for
   the given date.

Hope this may help you in little.

Cheers

Mn Karthik
 
Old August 26th, 2004, 06:40 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Mn Karthik

Thank you for your suggestions

1..ooohhh Activex. I am not a fan and seems like a huge overkill considering the vbScript function we have available.

2..Yes this is the option I have been using, I assume most do. There are allot of date/time function that allow us to tweak dates in any way we wish - I use:

  FUNCTION amDate(varDate)
    IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
      amDate = "Null"
    ELSE
      amDate = "" & Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & ""
    END IF
  END FUNCTION

This works nicely but as I said in my initial post:

"Q2..Isnt the point of having the ability to change system formats to do just this (the now function gets it's values from the system clock - therefore it should reflect it)?"

Any more input would be appreciated, Is this an XP/IE bug?

TY


Wind is your friend
Matt
 
Old August 27th, 2004, 03:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The ISO date format is yyyy-mm-dd, using this format it is impossible for the computer to get the date wrong, e.g. 3/5/04 could be 3rd May '04, or 5th March '04, however with 2004-05-03, there is no doubt at all that the date is 3rd May 2004. You can use this date format in your ASP script without any problems, therefore instead of returning the date in local format, you could return it in ISO format and it won't matter what the internal date format is, it is guaranteed to be understood:
Code:
amDate = Format(Year(DateValue(varDate)), "0000") & "-" & _
         Format(Month(DateValue(varDate)), "00") & "-" & _
         Format(Day(DateValue(varDate)), "00")
         Don't forget there is also the IsDate() function to test if a variable contains a valid date. I hope this helps.

Regards
Owain Williams
 
Old August 29th, 2004, 02:19 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Owain

Thank you for your input. Here in Aus we must use dd/mm/yyy

I guess i am looking for an answer to the following question:

Q2..Isnt the point of having the ability to change system formats to do just this (the now function gets it's values from the system clock - therefore it should reflect it)?"

If my system is set to dd/mm/yyy shouldnt the now function show this format?


Wind is your friend
Matt
 
Old August 30th, 2004, 06:18 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

As an update to this post, all is well now. Every thing on my machine was AU format except the LOCALE. My machine was formatted and rebuilt, this is why I lost my setting and ALL my asp pages built before the format were showing in correct date formats (on screen dates). Our network guy done the rebuild and changed the registry key to rectify this, I will track him down and post the key to change for other people who may have this problem.

I think the key to ensure this doesn’t happen is 'do your own rebuild'

TY


Wind is your friend
Matt
 
Old August 31st, 2004, 04:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am glad you found the answer to your problem, I appreciate that all dates must be returned in Ausie format as far as the client UI is concerned, however I find it a good practice to always handle dates in my code in ISO format (yyyy-mm-dd), this is true for entry and retrieval from a database (as long as the field in your DB is a date field then it will be saved as a date and the format in which it was inputted will not be stored). Then when you come to return the date to the client you can use the Format() function to provide the date in the appropriate format.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Up A Development System For This Course ebstr BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 13th, 2008 09:27 AM
setting system time angelboy C# 2005 1 May 4th, 2007 08:05 PM
Insert System date and System Time -Form _TextBox cnkumar74 VB How-To 14 February 14th, 2007 10:52 AM
Setting MySQL Permissions, Windows XP scrabala BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 November 2nd, 2004 05:09 PM
Installation error on XP system pavel Pro VB 6 1 February 5th, 2004 11:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.