How to get localdateTime format in JS - javascript

I'm using Vuejsto develop a project and I'm struggling to make my input type datetime get a min value . The min value has to be the value of the current Date and basically I need it to be formatted the same way it is supposed to be in the field. What I mean is it should have this format.
yyyy-mm-ddThh:mm.
I didn't actually find a way to do it with a built in function in JS.
<input type="datetime-local" min="{CurrentDateValueFormattedLikeThis:yyyy-mm-ddThh:mm}" v-model="tentative.startDate">

Related

How to format user input time format in JavaScript?

I have user input field that accepts time value. Here is example of that value: 03:45:15.0 I would like to format this value with JavaScript to format the time like this: 03:35:15 PM. Is there a way to complete this with Vanilla JS?
Thank you.

Netsuite! using freemarker to get the name of the month from a date DD/MM/YYYY doesn't work

Problem
I am working on an email template text whereby I would like to change the date DD/MM/YYYY to MMMM. There are two instances of it in the template. The two instances belong to 2 different date fields however their configuration is the same. Let's say I have date_field1 and date_field2. When I do the following in date_field1 it works fine but in date_field2 it doesn't and I get the following error.
I have checked the type of mydate just to make sure and it is a date. When I just do ?string it works fine and it does contain a date value but with .MMMM, it throws an error. Any help or suggestion will be great.
Code
Working: <#assign mydate1=transaction.date_field1 /> ${mydate1?string.MMMM?lower_case}
Not working: <#assign mydate2=transaction.date_field2 /> ${mydate2?string.MMMM}
Error
If you have an actual date field the format string is like:
<#assign mydate=transaction.date_field2?date["MMMM"]>
And of course there is no field called date_field2 so I assume that label is meant as a simplified example.
Note you can also try:
<#assign mydate=transaction.date_field2?string["MMMM"]>
But I think that was for a more recent version of Freemarker than Netsuite supports.
Finally you can set the overall string to date format which will be in place from the place in your code down to wherever you reset it. I found I had to set it for both date and datetime because some 'date' fields are interpreted by Freemarker as datetime even when they shouldn't be:
<#setting date_format="MMMM">
<#setting datetime_format="MMMM">
${transaction.date_field2}

Reformat date in PHP

I have a problem. I've a date input on my site. When the input type date is not supported by the browser, I'm initializing a jQuery datepicker.
The problem is, that the normal date input returns the value like this:
2019-08-23
And the datepicker this way:
26.08.2019
Instead adding a hidden field in the HTML, I want to re-format the received value via PHP to the first format above. So is there a way to build a small function that checks if the format is the datepicker format and which returns the formatted value like 2019-08-26?
I'm receiving the value with $_POST['date'].
Something like this should work:
echo date("Y-m-d", strtotime("26.08.2019"));
Reference: PHP strtotime()

Bootstrap datepicker setStartDate not working properly?

I am using Bootstrap datepicker and on selecting different values from a list its startdate is changing. It is working fine if I set the startdate 2013 from 2008 but it doesn't work if a select start date 2008 and currently its 2013.
What could be the reason here?
$('#datepicker').datepicker('setStartDate', updatedDate);
This line I am executing whenever I select different startDate.
Really need to know what updatedDate value is.
However, if you read the docs for the dtepicker the value passed in must be a string that is understandable by format
https://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#setstartdate
https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate
Date or String. Default: Beginning of time
The earliest date that may be selected; all earlier dates will be
disabled.
Date should be in local timezone. String must be parsable with format.
So what you pass in as the format option must match the format of your start date. If you do not set the format optin, the default is "mm/dd/yyyy"
Without seeing code, I can only hypothesize; try calling [...].datepicker('update', 'date_string'); on the object to force an update on the control.

Getting Value of input type time in angularjs

i am newbie in angularjs..
This is my form field:
input type="time" ng-model=mytime
The input type time gives me HH:MM: PM/AM from the above syntax.
I want to get the value of the field one by one using angular js.
how do I get my HH value using angular js ??
Also is there any way to integrate camera plugin using angularjs?
Please help.
In AngularJS, use the date filter to control the presentation of the date.
<input type="date" ng-model="mytime">
<input type="time" ng-model="mytime"><br>
{{mytime | date : 'd MMM yyyy hh:mm:ss'}}
For more information, see AngularJS date Filter API Reference.
For type="date" and type="time" inputs, ng-model returns a JavaScript Date object. All the standard Date methods are available.
var hours = $scope.mytime.getHours();
var month = $scope.mytime.getMonth();
// etc.
For more information, see MDN JavaScript Reference - Standard Objects - Date.
You could use split which will split a string into an array of substrings based on a separator. The hours will then be the first item in the array. You can do this like so:
var hours = $scope.mytime.split(';')[0];

Categories

Resources