Angular 2 Format Date Time Issue - html

I'm trying to format a date time value, my json call returns me a value like this:
2017-02-01T13:00:00.000Z.
And in my html code I have a p like this:
<p item-right>{{Solicitud.fecha_fin | date:"dd/MM/yyyy hh:mm"}}</p>
And this shows me this result:
01/02/2017 07:01
And that is wrong.

From experience the piping of date does not work on iOS and when building the application there will be errors so I recommend just getting the date string and slicing it in a separate function.

Related

How to retrieve date from database

I have a column in my database that is of type DATE.
I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).
r.setRkd(Date.valueOf(LocalDate.now()));
The entry is correct because the exact date appears in the table.
rkd
------------
2022-03-02
The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.
"rkd": 1646175600000
Do you know how I can print the correct date in my JSON?
Thank you in advance.
That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD
If you need to display it in date format there should be a method to do it depending on the specific language that you're using.

How can I reformat date using Flutter?

I'm using openweather 3hours forecast api. Why does the date show only the same time? even though values are different? date is supposed to be every three hours. I formatted the date in weatherItem.dart after iterating over each item.. how can I get the date with every three hours and render on the screen?
Looking at the JSON data you provided with the dt_txt key, you'll find that the date format does not contain time. So the JSON data you're getting does not contain a valid time you can use

How to pass a Date value to java API call in Different format?

I have a date column in my table, which will display a date as '17-MAR-15' format. Now I need to pass the date as 'DD-MM-YYYY(17-03-2015)' format to the Java API call. How can I pass this date parameter in that format?
You should take a look at: DATE_FORMAT
But basically what you do is this:
SELECT DATE_FORMAT(dateColumn, '%d-%m-%Y') FROM xyz;
Edit: Well, should have waited until I was really awake to answer, but if you happen to convert your date column to the date type this is how you would get the date in the specified format.

Showing Date in a specific format

I need to make the date format that I entered into the database look exactly the same as when i view it. Eg. Currently my format is 2013-12-21, but when i view it, it shows 12/21/2013. It's quite confusing because when I edit the date in my form, it's in the 12/21/2013 format and the database wont accept it when i change the date to something like 12/23/2013. Please help. Thanks
(btw, it just auto formatted my date. I didn't even use the <%formatdatetime%> function.)
EDIT: Sorry for the lack of information guys. This is what's happening.
1. I created a form to add date amongst othes to mysql. Eg. Purchase date, item, etc (sql wants it in yyyy-mm-dd format and that's how i enter it.
2. created a view list to select which rows i want to update. (Used
<%=Formatdatetime(f_purchasedate,2)%>
to show date only without time as it was 12/21/2013 12:00:00 AM)
3. created an update form.
Now the problem is it shows the date as 12/21/2013 instead of 2013-12-21. So when i submit the form after altering other fields, it says date error. I have to manually type the format 2013-12-21 for all my dates before i can submit the form.
i'm guessing it has something to do with this line of mine.
purchasedate.Text = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)
tried this but it doesnt help either...
formatDateTime('purchasedate').Text.ToString("yyyy-MM-dd") = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)
You can use DATE_FORMAT(date,format)
Select DATE_FORMAT('Your Date Value'),%Y-%m-%d) as Date from table_name
Or
You can pass the value to a variable like below
purchasedate.Text = CType(ODBCdataset.Tables("tbl_vehiclemanagement").Rows(0).Item(2).ToString, DateTime).ToString("yyyy/mm/dd")
Dim date As String = DateTime.Now.ToString("yyyy/mm/dd")

rails change date format before saving to mysql DB

I have a datepicker that I want to display in MM/DD/YYYY. However I'm using a mysql db which wants YYYY-MM-DD. As it stands right now its saving but the day and month are being reversed.
Right now I have an initalizer, date_time_formats.rb which has:
Date::DATE_FORMATS[:default] = '%m/%d/%Y'
Also in my datepicker jscript I have the correct format which I want to display:
$(this).datepicker({"format": "mm/dd/yyyy", "weekStart": 0, "autoclose": true, "startDate":new Date()});
I've tried things like this:
Date.strptime(params[:location], "%d/%m/%Y")
But I get a HashWithIndifferentAccess error.
How can I reformat the date in the params hash prior to assigning to an instance of the model? The reason being it seems to get rejected from the model if the date would be invalid (ex. April 4, 2013 is fine, but April 20, 2013 is not because there is no 20th month). I'm a big time rails novice so maybe I'm wrong but thats how it appears to be working. Thanks!
try the american_date gem located here: https://github.com/jeremyevans/ruby-american_date
Look up the strftime method of the various date classes. The incantation you want is Time.local(params[:location]).strftime('%m/%d/%Y'), hope that helps!
A quick way to sanitize the date to the correct format is to grab it in the controller before it gets saved and use strftime to correct the format. For example:
#model = Model.new(model_params)
#model.date_you_want = #model.date_you_want.strftime('%Y/%d/%m')
#model.save
This saves the date in the correct format. (I'm also using datepicker-boostrap gem)