How can we retrieve Specific date format data from database through JavaScript?
I am working with Javascript and for some requirement I need to connect oracle database and retrieve some data.
How can i read timestamp v开发者_开发问答alues from oracle database in java script please provide me the method or any help.
i have checked my database and the format Is "YYYY-MM-DD HH:MM:SS,fffffffff" How can i read this time stamp value.
Thanks
Lr
you could use oracle's datetime conversion when you select the data TO_CHAR( datetime, format )
like this you can get the datetime as a string from you db in any format you want and don't need to change the format later in Javascript.
see Oracle Format Models
simple example:
SELECT TO_CHAR( SYSDATE, 'MM/DD/YYYY HH24:MM:SS' ) AS TS FROM DUAL
or if you want only the time without date:
SELECT TO_CHAR( SYSDATE, 'HH24:MM:SS' ) AS TS FROM DUAL
If in JavaScript you get a timestamp, then just use
new Date(timestamp)
Cannot be done through JavaScript.
You need a webservice that outputs the required data in a specific format (preferably JSON) and use AJAX (http://api.jquery.com/category/ajax/) to fetch it.
精彩评论