Kendo Timepicker: Save in different format than parseFormat - asp.net-mvc-4

In our project our server expects time values to be a string in 24-hour format (HH:mm:ss). However we want to use kendo timepickers that display 12-hour format with AM/PM (hh:mm tt) to the end user. Right now I am using:
$('.timePicker').kendoTimePicker(
{
format: "hh:mm tt"
parseFormats: ["HH:mm:ss"]
});
And this works fine in terms of displaying the correct value from the database. However the problem is that the value of the field is saving back out to 12-hour format (hh:mm tt) instead of 24(HH:mm:ss).
What can I do to display 12-hour format but save 24-hour?
Thank you

On your Controller , when you populate your Grid view . . Add this
Convert.ToDateTime(row. *Value of the Timepicker*).ToString("hh:mm tt")
Then on Saving, Add this on your controller
Convert.ToDateTime( *value of your Timepicker*).ToString("HH:mm:ss")

Related

Datepicker submit format

In the new version of materialize the new 'datepicker' seems to have lost the option for 'formatSubmit'
format: 'dd/mm/yyyy'
formatSubmit: 'yyyy-mm-dd'
You use to be able to display the date in the page in one format and submit it in another.
Anyone have a way round this?

How to sendkeys "time" in time type element?

I need to pass data in time format in "time" type element in "10:00 AM" format.
I am using following code:
public static void setShift()
{
txttime.sendkeys("1030AM");
}
this is not working. what is a correct way to enter such data?
Use Following Code :
It will work it for textbox/text area control
SimpleDateFormat formatter = new SimpleDateFormat("hh:mm a");
Date date = new Date();
txttime.sendkeys(date);
For the HTML input type datetime-local handling it from selenium is not ideal. It is not the most used date time picker, and it is not supported in firefox or safari.
For chrome, the date time format shows the format set in the browser's machine.
If you haven't changed anything, I'm guessing you are getting the format shown in the guru99 tutorial.
If that is the case, then you have missed that they also have provided the solution there.
After entering the date part you need to press tab to input the time part. Which is missing from your given code.
Try this:
First, input the date
WebElement dateBox = driver.findElement(By.xpath("//form//input[#name='bdaytime']"));
dateBox.sendKeys("09252013");
Second, press tab
dateBox.sendKeys(Keys.TAB);
Last, input the time
dateBox.sendKeys("0245PM");
Note:
If your machine has different DateTime formatting then this might not work. You have to check which part of the date time senKeys can actually input then split up that part and use Keys.TAB to press tab. Then input the next part until completion.

How to set string to datetime widget?

The title is self explanatory. I am having difficulties setting a string value to a date time widget.
XCP has a build in function stringToDate
which i use in these examples...
1. stringToDate('5-5-2009')
2. stringToDate('05-05-2009')
3. stringToDate('5/5/2009')
But non of them work. What am I missing here ?
Also i set the value of the widget in the behaviors tab of the date widget.
If you are talking about Date-Time Input widget then you need to use dateToString not stringToDate.
I figured out the issue. It's dependent to the format in which you save your date to string value. If we save the Date-Time Input widget value in this format:
dateToString('12-12-2018', 'm-d-Y')
then doing a :
stringToDate(savedvalue) will work only when the format saved was 'm-d-Y'. It wasn't working before because i saved it as 'd-m-Y'.

Bootstrap 3 - DateTimePicker - Can time portion be ignored?

I'm using the Bootstrap 3 DateTimePicker. When the user tabs into a field using this component, the current date and time is automatically entered. In some cases this is what I want. However, there are other times I want the component to completely ignore the time portion and not entered by default in a field. I can't seem to find a way to do this.
This will only display the date by default, try and see
$('.future');.datetimepicker({
pickTime: false,
format: 'DD/MM/YYYY'
});

DD-MMM-YYYY date format possible for input

is a DD-MMM-YYYY (17-Oct-2012) date format possible for input?
I have tried to add below property in properties-local.xml for Input Date field.
<property as="xs:string" name="oxf.xforms.format.input.date" value="[D01]-[MNn,*-3]-[Y0001]"/>
Date field is coming as : 17-10-2012 after selecting date from calendar.
For xforms:output, same [D01]-[MNn,*-3]-[Y0001] is displaying : 17-Oct-2012
Please suggest. Is this [D01]-[MNn,*-3]-[Y0001] format acceptable for oxf.xforms.format.input.date?
Instead of adding a property for input, do the following which might help you.
use xxf:format attribute for input control and use format-date function to get the expected format after selecting the date picker.
ex:-
xxf:format = format-date(.,'[D01]-[MNn,*-3]-[Y]')
Regards,
Arjun