Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET DateTime script
How to display Date Time while printing a document.
Hi friends, I need todays date on printed page.
By the way am working on 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 ='', '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("<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>");
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 20:11pm
Edited 4-Feb-13 20:13pm

1 solution

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

Solution 1

add below line in your code, where you want to print date
prtwin.document.write(new Date());
HYD Webdeveloper at 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 at 5-Feb-13 3:49am
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
0 Sergey Alexandrovich Kryukov 9,580
1 OriginalGriff 8,370
2 Peter Leow 4,859
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2015
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