show date in correct format angular - node.js

I am making an application in which I want user to submit date date is getting stored in database in this format 2003-06-01T00:00:00.000+00:00 I want to display it as 01/06/2003 or 1st June 2003 can any body help me how can I do this?

You can use angular date pipe
https://angular.io/api/common/DatePipe
<span>{{startDate | date:'MM/dd/yyyy'}}</span>

I have created a small stackblitz for this. You can see date being formatted 4 different ways here:
Plain old javascript date
Formatted Javascript Date
Using Angular Pipe in HTML file
Using formateDate() function in component.ts file.
Please refer to this link: https://stackblitz.com/edit/angular-cue9h6?file=src%2Fapp%2Fapp.component.html

You could use date pipe to format your standard ISO date in html template. Find the date object from your template, wrap the value in {{}} and then add | date pipe to format it. https://angular.io/api/common/DatePipe
<td>{{date}} </td>
<td>yyyy-MM-dd</td>
<td>{{date | localDate:'yyyy-MM-dd' }}</td>
<td>{{date | date:'yyyy-MM-dd'}}</td>
Here is a working example: https://stackblitz.com/edit/angular-local-date-pipe-bu2nxp?file=src%2Fapp%2Fapp.component.html

Related

Date cannot be pasted on chrome with using VBA - Selenium

I can change date on web page if I use internet explorer with below code(code1).
however, I changed browser to chrome with selenium. (as code 2), date section on web page is changed but it is partial.
for example: date is set 18/02/2020 on web page when it is opened. then I want to change date as 01/03/2017 but it is changed to 03/02/2017. that means, month section in macro shanged the date section, nothing changed on month section and year section is also changed
i have tried to change date order in macro like mm/dd/yyyy but ı cant get a proper date solution. just tried millions of code and still cannot find anything.
so please help me to change date section on chrome with using selenium.
Sheet1.Range("A1") = 01/03/2017
Code1
ie.document.getElementsByName("date$From")(0).Value = Sheet1.Range("A1").Text
Code2 (selenium and VBA)
obj.FindElementById("date_From").SendKeys (sheet1.Range("A1")).Text
Website code (website is behind a firewall)
<input name="date$From" type="text" value="18/02/2020" size="6" id="date_tbFrom" class="searchSelect">
<input type="hidden" name="date_From_Client" id="date_From_Client">
found a solution bymelf with try it. I used tab button usage to reach date section and used date format as 01,01,2021. used comma (,) instead of slash (/) as date seperator.
obj.FindElementByName("date$From").Clear
obj.FindElementById("place_before_date").Click
obj.SendKeys (keys.Tab)
obj.FindElementById("date$From").SendKeys (Sheet1.Range("A" & x))

Changing date format in display templates for SharePoint 2013

I have a Content Search Webpart that uses a customized Display Template to display results of recent changed documents.
I would like to show the "last modified-date" below the document Title.
I can then use #= ctx.CurrentItem.ModifiedOWSDATE =# to get the date, however the returned date is displayed as 2013-05-16T12:54:10Z.
How can I format the date so it is displayed like 16.05.2013 - 12:54 ?
iirc SharePoint should handle the date conversion if you use the same approach as you do with new Property Mappings.
Copy/paste a variable in the template, something like:
var modifiedDate = $getItemValue(ctx, "ModifiedOWSDATE");
modifiedDate.overrideValueRenderer($contentLineText);
And use that variable instead:
<p>_#= modifiedDate =#_</p>
If creating a new custom Value Renderer etc is not an option for formatting the date (The default pattern used by Search.ClientControls isLongDatePattern I think). One could always create a Date variable, and do as fit:
Example:
<p>_#= new Date(modifiedDate["inputValue"]).toLocaleString() =#_</p>

Powershell dates to Sharepoint Dates

I have an old site that I am trying to convert to sharepoint. I have a database that stores the original upload date of the document. I need to get that date into a sharepoint column called "Original Upload". The "Original Upload" column is in a date/time format and only displays the date like "10/5/2009". I created a Powershell script to grab the date from the database and use it to change the "Original Upload" date in sharepoint. The problem is I keep getting a powershell error of "invalid date/time".
Powershell formats the date from the database as "Friday, May 06, 2011 7:52:12 AM". Sharepoint does not accept this date format. Sharepoint also does not accept strings. I was able to change the format of the powershell date to "5/6/2011" (the format on the sharepoint site), but it is converted from an object to a string, which doesn't work.
How do I convert a powershell date to "5/6/2011" and keep it as an object so Sharepoint will accept it?
Thanks
Sharepoint accepts iso date format which have format:
yyyy-MM-ddThh:mm:ssZ
in your example:
2011-05-06T07:52:12Z

How to get the Current Date & Time Automatically to a Date Time Field

I have created a date time field I made today's date as the default value, Then I added it to a page layout and created a page, But the current Date Time is not picking up from the system.
I dont want to give the user to select a Date Time instead it should populated automatically
Is there anyway to achieve this without writing code in code behind files?
This is very similar to this question I think
SO - How to get Date and current time from the Date/Time column in SharePoint Custom list
My answer there gives a few options such as using the built in Created field, using a calendar template, a JavaScript hack and a custom field type.
Guys, fake [Today] trick worked for us - but prob is we only got the date value not datetime.
Janis, is it possible to get date and time both from the fake [today] column trick? pls refer few articles on the same
Does [Today] work?
If you have language pack applied to SharePoint, then you must use localized "Today" string.

Modx assign default date to template variable

I have a template variable of input type date but I'd like to have a default value of the current date at the time the document was first saved.
I've noticed that using the date formatter widget gives an option to "If no value, use current date" however it seems to use the date at the time it is being viewed rather than the date at the time the document was created.
Any help appreciated.
I think the only way to get the date when the article was saved for the first time is to use [ * createdon * ]
If there is a way to add the created date to a TV, I am not sure. I think your best shot would be to see if you have an event that you could "hook" you Template Variable, and then use the createdon variable everytime the article is saved! I am not sure this works, but This could be a possible!

Resources