Gossamer Forum
Home : Products : DBMan : Customization :

mm/dd/yy format -- yes, it's been covered but i can't get it to work!

Quote Reply
mm/dd/yy format -- yes, it's been covered but i can't get it to work!
Hello,

I'm fairly new to customizing cgi scripts, though I've used DBMAN for about a year now. Anyways, I'm updating the site and want to change the way the dates are displayed. I found the message thread here:

http://www.gossamer-threads.com/...m.cgi?post=9848#9848

and read the whole thing and made the appropriate changes to my db.cgi file. The records display the date correctly but when I go to add a new record, I get it in mm/dd/yyyy format. I want it just to be mm/dd/yy if possible?

My file is on my server as http://jherusalem.com/quoted/db_cgi.txt if you need to see what I've done to the code.

Thanks very much!
'Salem ~ http://jherusalem.com

Last edited by:

jherusalem: Nov 5, 2002, 7:57 PM
Quote Reply
Re: [jherusalem] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
Taken from the FAQ under "Dates"

Displaying just part of the date

If I have a field called Date, and the standard format is 29-May-1999, is there a way to display just the 29-May portion of it? I still want the field to contain the 1999, but I want to show just 29-May.

Response:

You can use something like:

$part_date = substr($rec{'Date'},0,6);

This would be used with either html_record or sub html_record_long in your html.pl file after my (%rec) = @_;
Then use the variable $part_date to print it out.
------------------
JPD

So in your case you may want to try using (to show the first 9 characters):

$part_date = substr($rec{'Date'},0,9);

Hope this helps

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
Hmm, well, I modified it to:

$part_date = substr($rec{'Date'},0,8);

and now I get 11/05/20! Oy vey. Thank you for your help, though. I'll keep looking.
'Salem ~ http://jherusalem.com
Quote Reply
Re: [jherusalem] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
Not being a perl programmer, I would, however, guess that you could use:

$part_date=substr($rec{'Date'},0,6);

$yr_date=substr($rec{'Date'},9,2);

Then print as $part_date $yr_date. Try it. I haven't the time!
-------------
David Olley
Anglo & Foreign International Limited,
http://www.firehelmets.co.uk

There are 10 types of people in the world: those who understand binary, and those who don't.
Quote Reply
Re: [davidolley] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
Thanks for the suggestion! I had to change it to read $yr_date=substr($rec{'Date'},8,2);
and it populates the date field on the add screen well enough, but when you try to add the record, I get a "Date Format Invalid" error.

*sighs* Oh well. Thank you very much both of you for your help. I have the site up and running MOSTLY the way I'd like, so I guess I can't complain too much, you know? Well, I could, but who would listen? Wink

Thanks again!
'Salem ~ http://jherusalem.com
Quote Reply
Re: [jherusalem] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
You are wanting people to be able to enter dates in the format you stated and not just display the partial date?

If so, you would need to install the date translator mod, which is available either in the Resource Center or on JPDeni's site at http://jpdeni.com/dbman/

The mod allows you to enter dates in various formats.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
Actually, I'm the only one who has admin rights to the database. What I want is for the date to display in a particular format (mm/dd/yy) when I go to add an entry so that I don't have to change it ... mostly because I know I'll forget. mm/dd/yyyy is fine but a little bulky on my "what's new" list, but that's the only place it shows up so I guess I can live with it. I did install that mod, which is how I get mm/dd/yy to work instead of dd-month-yy. At least it works. Smile

Thanks again!
'Salem ~ http://jherusalem.com
Quote Reply
Re: [jherusalem] mm/dd/yy format -- yes, it's been covered but i can't get it to work! In reply to
In your .cfg file for the field definition you can you either:

'Date' => [ 2,'date',10,10,1,&get_date,''],

or:

'Date' => [ 2,'date',10,10,1,&get_date,'\d{2}\/\d{2}\/\d{2}'],

to have it automatically add the current date in the record. You may find other ideas in the FAQ the second option doesn't work correctly.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/