0
Time Format in ASP/Javascript
Explorer
,
/t5/dreamweaver-discussions/time-format-in-asp-javascript/td-p/1019923
Aug 17, 2006
Aug 17, 2006
Copy link to clipboard
Copied
I'm trying to format time in an ASP/javascript page in
Dreamweaver that is being pulled from an Access 2003 database. The
default format has seconds displayed which I do not want. In
Dreamweaver you can choose formatting, however, none of the choices
are what I need. What I want is non-military time, no seconds
displayed and I do want AM/PM. So, this is what I would like to
see:
4:45 PM
The Dreamweaver formatting gives me the following:
04:45:00 PM
04:45:00
16:45
None of these are useful to me. Does anyone know how I can get my time to display correctly?
thanks,
Winona
4:45 PM
The Dreamweaver formatting gives me the following:
04:45:00 PM
04:45:00
16:45
None of these are useful to me. Does anyone know how I can get my time to display correctly?
thanks,
Winona
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/time-format-in-asp-javascript/m-p/1019924#M187821
Aug 17, 2006
Aug 17, 2006
Copy link to clipboard
Copied
You should be able to use some code from this page and turn
it into what you
need.
http://www.web-source.net/web_development/javascript_date.htm
It's not all applicable as you do not want to create the date object, as
that code does, but the principles you need to employ are the same for
getting the hour and minute portions out of your stored date and also
working out the AM PM part and displaying that too.
I hope that helps.
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
need.
http://www.web-source.net/web_development/javascript_date.htm
It's not all applicable as you do not want to create the date object, as
that code does, but the principles you need to employ are the same for
getting the hour and minute portions out of your stored date and also
working out the AM PM part and displaying that too.
I hope that helps.
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Winona
AUTHOR
Explorer
,
/t5/dreamweaver-discussions/time-format-in-asp-javascript/m-p/1019925#M187822
Aug 17, 2006
Aug 17, 2006
Copy link to clipboard
Copied
Unfortunately I'm a novice and I don't know enough about
javascript to pull it together. I'm using Dreamweaver 8,
ASP/javascript and an Access 2003 database. This is the field being
pulled in using ASP:
<%=(appointment.Fields.Item("AP_AppointTime").Value)%>
My question is how would I write the javascript to use that field as a variable then how would I call in the javascript?
<%=(appointment.Fields.Item("AP_AppointTime").Value)%>
My question is how would I write the javascript to use that field as a variable then how would I call in the javascript?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/time-format-in-asp-javascript/m-p/1019926#M187823
Aug 22, 2006
Aug 22, 2006
Copy link to clipboard
Copied
You should be able to drop this code onto the page where you
want the time
to appear.
This is just a quick and dirty chunk of code that I put together and have
not tested.
Please bear in mind that I do not code in ServerSide JavaScript (I use
VBScript) so the code might not be accurate...
<%
var now = (appointment.Fields.Item("AP_AppointTime").Value)
var hour = now.getHours();
var minute = now.getMinutes();
var ampm = "AM";
if (hour>11){
ampm = "PM";
}
response.write(hour + ":" + minute + " " + ampm);
%>
I hope that helps.
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
to appear.
This is just a quick and dirty chunk of code that I put together and have
not tested.
Please bear in mind that I do not code in ServerSide JavaScript (I use
VBScript) so the code might not be accurate...
<%
var now = (appointment.Fields.Item("AP_AppointTime").Value)
var hour = now.getHours();
var minute = now.getMinutes();
var ampm = "AM";
if (hour>11){
ampm = "PM";
}
response.write(hour + ":" + minute + " " + ampm);
%>
I hope that helps.
Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

