Customising date field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Customising date field

Post by madhu »

Dear All,

Can any one know how to customise a date field??

Code: Select all

$today_display = date("m/d/Y H:i");
Thanks and regards
MADHU
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Customising in what sense? If you want to change the format of the date you just need to change the "m/d/Y H:i" bit ... details of that stuff are all in the manual.
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Hi all,

The created xls file contains a date field as 02/20/2007 09:39 (date("m/d/Y H:i")).

Am able to write the content(02/20/2007 09:39) in the xls file.

Problem:

when we saw the properties of that cell,

(How to see properties: rightclick on that cell->go to Format Cells->go to Number tab)

in that it should show as

1)Category as Custom
2)Type as m/d/yyyy h:mm


But it is showing as

1)Category as General
2)Type as General format cells have no specific number format


If any one knows how to make date field as custom field insteadof General,Please help me.

Thanks and regerds
MADHU
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Did you specify the format to excel?
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Please tell how to specify format to the excel???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you generating an actual Excel file, or a CSV?
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Am generating actual Excel file.

code:

Code: Select all

require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$dir = getcwd();
$today = date("ymdHi");
$today_display = date("m/d/Y H:i");
$source_file = $today.'.xls';
$remote_file = $today.'.xls';
$fname = tempnam($dir, $source_file);

$workbook = &new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet();

$worksheet->write(0, 0, 'USERID');
$worksheet->write(0, 1, 'PASSWORD');
$worksheet->write(0, 2, 'ADDRESS');
$worksheet->write(0, 3, 'CITY');
$worksheet->write(0, 4, 'COUNTRY');
$worksheet->write(0, 5, 'PIN');
$worksheet->write(0, 6, 'PHONE');
$worksheet->write(0, 7, 'FIRSTNAME');
$worksheet->write(0, 8, 'LASTNAME');
$worksheet->write(0, 9, 'COL_TIME');

$worksheet->write(1, 0, "madhu@bsepaper.com");
$worksheet->write(1, 1, "12345678");
$worksheet->write(1, 2, '' );
$worksheet->write(1, 3, "Akranes");
$worksheet->write(1, 4, "Iceland");
$worksheet->write(1, 5, '');
$worksheet->write(1, 6, '');
$worksheet->write(1, 7, "Madhu");
$worksheet->write(1, 8, "Hari");
$worksheet->write(1, 9, '1234');

$workbook->close();
$fh=fopen($fname, "rb");
chmod($fname,0777);
copy($fname, $dir.'/'.$source_file); //copy from temp to source file
If you want class.writeexcel_workbook.inc.php,class.writeexcel_worksheet.inc.php and the included files,then i will send.

Please help me.

Regards
MADHU
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Check the documentation for the class you are using on how to specify the format of a cell.
Locked