I am saving the date to SQL database from nodejs. While saving the date to SQL I am getting error " parameter.value.getTime ".
While passing a date in this format while passing it to SQL.
2018-06-27T18:30:00.000Z
In early records in the database, DateTime format is this one.
2018-05-25 14:39:19.433
How can I solve this error? I already used moment js to use another format for saving the date but it is not working.
You should not try to change the format of your String, but convert it into JavaScript Date instead:
var yourDate = new Date(yourString);
Related
I use in Database with type date. I wrote example in field 12.12.2012.
If execute request in DB example:
"Select date From Date" => I get 12.12.2012.
I get 12.12.2012.
I use node.js for send data on client and get 12.12.2012:00:00:00.
Mayby not properly entry in variable callback?
The date you received '12.12.2012:00:00:00' includes the time as well as the date. You can look at it in two parts where '12.12.2012' is the date, and '00:00:00' is the hours:minutes:seconds of the day. Read more here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date.
I have a date field which contains data coming in from the database as 2015/07/31 13:01:53.180z.
Datetime is stored in UTC on database.
My code looks like this:
var startDateTime = Ext.util.Format.date(StartDateTime, 'm/d/y g:i:s A');
But the output I get is the conversion of UTC to IST(Indian).I checked on Chrome,Mozilla and IE.
I got same output all the time
Does ExtJs does this? Because I haven't wrriten any method for conversion.
I use ExtJs 4.1.1
I would appreciate any help on this.
Timezone is appended in the string->JS Date conversion.
To parse the date from database without timezone conversion you should use the Ext.Date.parse explicitly, not automatically through model field type 'date' or simply JS constructor new Date().
For example:
var db_date = '2015/07/31 13:01:53.180z',
js_date = Ext.Date.parse(db_date.substring(0,db_date.length-5), 'Y/m/d H:i:s'),
date_to_show = Ext.util.Format.date(js_date, 'm/d/y g:i:s A');
Obviously "substring" must be replaced by something better, for example you could format db date (cutting timezone part) in the web service serialization.
If you achieve to clean the date string in the web service you can also add "dateFormat" attribute to model fields to parse date correctly into models.
I'm using the module dataformat to get a data from a timestamp but I get an error and I can't understand why.
that's the timestamp 1405303200 and I need the Date in this format dd/mm/yyyy
That's my code
var day=dateFormat(result.request_date, "dd/mm/yyyy");
But what I get is the 1970-01-17 date asd.
I think you are using a timestamp saved by PHP... now convert it to miliseconds
var timestamp = 1405303200 *1000;
I'm trying to store 05/09/2014 11:57 am into MySQL timestamp data type and it's putting in null or '0000-00-00 00:00:00' into the database. I want to store something like 05/09/2014 11:57 am. I'm using this, http://www.jqueryrain.com/?lnsG0UbP, datepicker to get my date and time. Any help is much appreciated.
Make sure to format your date accordingly. For reference: http://dev.mysql.com/doc/refman/5.7/en/datetime.html
Did you use the date() and strtotime() function?
I am working with Javascript and for some requirement I need to connect oracle database and retrieve some data.
How can i read timestamp values 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.