Page 1 of 1
Customising date field
Posted: Mon Feb 19, 2007 5:39 am
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
Posted: Mon Feb 19, 2007 6:57 am
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.
Posted: Mon Feb 19, 2007 10:22 pm
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
Posted: Mon Feb 19, 2007 11:27 pm
by feyd
Did you specify the format to excel?
Posted: Tue Feb 20, 2007 12:01 am
by madhu
Please tell how to specify format to the excel???
Posted: Tue Feb 20, 2007 12:30 am
by feyd
Are you generating an actual Excel file, or a CSV?
Posted: Tue Feb 20, 2007 1:16 am
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
Posted: Tue Feb 20, 2007 8:05 am
by feyd
Check the documentation for the class you are using on how to specify the format of a cell.