how to set datepicker default date to custom date in angularjs? - angularjs

i change datepicker default date to custom date.this is working correctly,
but i want empty text field in starting time.
similar useful code is
http://jsfiddle.net/DwT8M/
my example code is
http://plnkr.co/edit/H7vezOLLPkTSp085v7wa?p=preview
[1]: http://jsfiddle.net/DwT8M/
[2]: http://plnkr.co/edit/H7vezOLLPkTSp085v7wa?p=preview

Related

how to show date time in datetime picker according to timezone using datetimepicker of anuglarjs indrimuska

I want to set min-date option on datetimepicker and also want to set this option according to the timezone of selected location.
for example :
$scope.minDate = moment().subtract(0, 'month');
but this statement set minDate according to local time instead of selected location timezone. Please, anyone, tell me the solution that how can i set minDate according to the timezone and how to solve this problem because I need the solution
I am using angularjs and its indrimuska plugin to show datetimepicker.
Here is the link of the documentation.
You can use moment timezone for getting a date for your desired timezone. Like in the following example
$scope.minDate = getDateFromTimezone('America/New_York');
function getDateFromTimezone (employeetimeZone) {
return moment().tz( employeetimeZone).format("MM/DD/YYYY");
}

angular: uib-datepicker locale is not set dynamically

Consider the following setup: I have a form with a angular-bootstrap datepicker (uib-datepicker-directive), which I want to serve with different languages, such that dates are shown in different formats.
I am changing the locale dynamically with the angular-dynamic-locale-module, by using information from the state parameters.
A date object is printed with correct language-specific format using the angular date filter: {{vm.date | date:'fullDate'}}
Unfortunately the formatting for the datepicker is not working immediately. When loading the page and call a set-locale function it needs a click into the datepicker to adjust the format of the month and click to the month and back to additionally adjust the translations for the weekdays.
I have created a plunkr to demonstrate the behaviour.
http://plnkr.co/edit/2HA8LI5SzUqx2jSmUdjn?p=preview
Does anyone know this behaviour? And if so, is there a way to fix this, preferably without messing up the datepicker directive?
Thanx in advance, micoud

Angular UI datepicker - date format from API

I'm using the Angular UI datepicker component. When my data comes down from the API, I get dates in this format in the JSON:
"date": "2015-10-21T00:00:00"
The datepicker is correctly formatting the date in the input field to "21 October 2015". But, if I click the submit button on the form, without making any changes, the date field fails validation.
If I set the date model to a date object (as opposed to a string) like so, after the JSON loads:
vm.date = new Date();
Then the validation works.
So it seems the datepicker component doesn't set the date correctly, when using a string value as the model.
Any way to fix this?
Here is a link to a plunkr:
http://plnkr.co/edit/gAhme7fmIPgbojYVJlNU?p=preview
If you choose a date using the datepicker calender, it works fine. But if the date gets set using the button, as it would using JSON API data, then it fails validation.
Looking into the source code it seems that the model date can be set as timestamp (number) or as date object, but NOT as string. A string is expected as an input value and will be parsed with your custom data format dd MMMM yyyy.
See datepicker.js 780-800

Angular Bootstrap DateTimePicker - Highlight Today Date on embedded Calender

Please accept my apologies if i had any mistakes in my post. This is my first post here. But, i am not new to StackOverflow. Correct me if any.
I am using angular-bootstrap-datetimepicker library from the below url:
Link to library
I am currently embedding the calender on the page.
I am using angular.js, moment.js, grunt and bower. Absolutely no issue loading the calender and can even select a date and display the selected date as well.
Here is the sample code:
<div>
Selected Date: {{ data.embeddedDate | date:'yyyy-MMM-dd' }}
<datetimepicker data-ng-model="data.embeddedDate" data-datetimepicker-config="{ startView:'day', minView:'day'}" />
</div>
I am trying to highlight today's date automatically when the datetimepicker shows on the page.
As you can see, in the config options, i could set the default view and min view.
Note: I tried to mimic the working code (till now) in Plunkr but, its not showing the calendar. I added all libraries as well. Anyways, that's just for idea only. If i could get the Plunkr working, i will update again.
Here is the link to Plunkr.
Any suggestions (regarding highlight today date by default) will be appreciated.
To get the directive to show todays date by default, you can set the value of data.embeddedDate in the controller through its scope, like so:
$scope.data = { embeddedDate: new Date() };
Working Plunkr

Angular JS formate date

Is there any directive in Angular, I want to enable user when he write 2/3/67 in input for date date needs to be formatted like 02/03/1967 I tried few things on my own but they didn't work.
Just add a Angularjs formating, when displaying users input like so
{{yourdate.variable | date:'yyyy-MM-dd'}}
Se more at AnguarJS date function
EDIT
Here is working Plunker, with different type of dates. Enjoy

Resources