Click here to Skip to main content
13,007,145 members (58,435 online)
Rate this:
 
Please Sign up or sign in to vote.
How to display Date Time while printing a document.
---------------------------------------------------

Hi friends, I need todays date on printed page.

By the way am working on Asp.net c#

Iam printing Gridview Data.

This is my code SCRIPT

<script type="text/javascript">
function PrintGridData() {
var prtGrid = document.getElementById('<%=GVStudentsAttendance.ClientID %>');
prtGrid.border = 0;
var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
var logoData="";
prtwin.document.write("<div align='center'><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:22px;align;text-align:center'>King Khaled International Airport</span><br/><br/><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:18px;align;text-align:center'>Students Attendance</span><br/><br/><br/></div>");
prtwin.document.write(prtGrid.outerHTML);
prtwin.document.write("<div align='center'><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:22px;align;text-align:center'>Prepared by KKIT Department</span><br/><br/><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:18px;align;text-align:center'>Date here</span><br/><br/><br/></div>");
prtwin.document.close();
prtwin.focus();
prtwin.print();
prtwin.close();
}
 
</script>

This is Html Image button
<img alt="Print Report"  önclick="PrintGridData()"  src="imagesVO/print_icon_Nahil.gif" title="Print Report" />

Please can you help me, how to display todays date in printed document.
Posted 4-Feb-13 19:11pm
Updated 4-Feb-13 19:13pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

hey,
add below line in your code, where you want to print date

prtwin.document.write(new Date());
  Permalink  
Comments
HYD Webdeveloper 5-Feb-13 2:51am
   


Sir, it is displaying like this.

Tue Feb 05 2013 10:44:46 GMT +0300 (Arab Standard Time)

------------------------------------------------------------

BUT I need it as, 05/02/2013 10:44 am

Please can you show me , how to display like this. THANKS.
ssd_coolguy 5-Feb-13 3:49am
   
http://www.w3schools.com/js/js_obj_date.asp

try above link..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100