How to format date in Angular 4? - html

App using Angular 4 and bootstrap. I am using an input field that gets the date with month and year (type=month). But when the date saves, I am seeing "yyyy-mm" order. That is fine, but how can I switch the order in the client view to show mm-yyyy or even January 2018?

You would use the date pipe structure:
{{ dateExpression | date: 'mm-dd-yyyy' }}
There is a good short page about it here that you can read and expand on.

Related

Can't compare dates in Angular 2+

I have 2 dates that I need to do some logic. The first date comes from SQL database and the second date is the current date that from angular.
I would like to display them in an HTML table if the SQL date is earlier, apply css stylebehind and later, apply ahead css style.
my current date that I use in component.ts is:
today: any = Date.now();
And my HTML table that I use ngIf is:
<td *ngIf="p.serverDate >= today" class="ahead">{{ p.serverDate | date }}</td>
<td *ngIf="p.serverDate < today" class="behind">{{ p.serverDate | date }}</td>
p is the object that returned from database that has date in it. I am ppretty sure that I have the serverDate and today. I can use date pipe on both of them. Why can't I use the simple if statement in here?
UPDATE: I've just found out that
serverDate is 2018-07-24T20:34:48 and today is 1533235371115 format.
Might be date from MySQL DB might be in string. You need to convert using new Date().
For any date manipulation, you can check moment.js library or date-fns library. For comparison b/w dates use isBefore() method in https://momentjs.com/docs/.

Angular 2 Format Date Time Issue

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.

Date/Time formatting in access textbox

I have an issue, and believe its simple to resolve but cant work out how.
My table, which has showing both date & time can not be amended because that is how I receive my data.
Ive changed the format in the table design to short date and it shows fine, it hides the time.
I also changed the textbox that displays the date to short date but its still showing both the date and time, why?
Primarily, I have another textbox that I want to calculate the table date + 30, my expression used is:
=[text5]+30
The textbox is displayed blank.
Any help?
It sounds like your date field is linked as text. So convert to Date:
=DateValue([OpenedDate])
and for the +30 date:
=DateAdd("d",30,DateValue([OpenedDate]))
However, there is no way that:
? DateValue(Now() + 30)
can show today's date. It will show 30 days ahead of today.

Laravel edit form won't display old date if it is in format `0000-00-00 00:00:00`

I have a standard edit form for all my models:
{!! Form::input('date', 'date_event', #$object->date_event) !!}
problem
If the date format stored in my MySQL database is like this 2017-02-25 17:00:00, the #$object->date_event would not set the datepicker properly - as a result the form would store 0000-00-00 00:00:00 when I submit it.
It is destructive - the old value of this field is erased.
Additional notes:
I have changed cell type to datetime, varchar(32), timestamp - partly just to experiment with the problem. I have concluded that the necessary condition to show the date is to store it in this format 0000-00-00
But I need hours and minutes too.
datepicker
in Chrome I don't use any extra datepicker. I use version 50.0.2661.102 m
in Firefox the datepicker is not working at all - the field acts like a text type.
To do:
make the form see the date even if it is in this format: 2017-02-25 17:00:00.
Thx

Jekyll - Get the date of the last post

I know that i can get the post date with post.date.
But, how i can get the date of the last post or the date related with the last time the website was generated?
I want to echo something like this:
Last update: {{ getDate }}
You want site.time, which will show the exact date/time when the site was last generated:
2015-07-22 17:11:02 +0200
To output the exact date format you want, you can use Liquid's date formatting.
For example, {{ site.time | date: "%-d %B %Y"}} will generate 22 July 2015.