I have a binding value, which is DateTime DataType and I'm trying to convert it into Time only, it's in this context Text="{Binding AppointmentDate.Value.ToString("H:mm") }"
in the label but this is not working and gives errors, How can I convert it and use only time without touch c# file?
Change time format this way .
<Label Text="{Binding AppointmentDate, StringFormat='{0:MMMM dd, yyyy}'}"></Label>
<Label Text="{Binding AppointmentDate, StringFormat='{}{0:hh\\:mm}'}"></Label>
Related
I want to display this time format in ion-datetime. Both date and time I want to display.
But when I am assigning this value to ngmodel it is not displaying.
Can anyone please help me how to do this.
You can use displayForamt attribute to show date like this.
Check Example blow.
<ion-item>
<ion-label>D MMM YYYY H:mm</ion-label>
<ion-datetime pickerFormat="YYYY/MM/DD H:mm:s" displayFormat="YYYY/MM/DD H:mm:ss" min="1997" max="2010" [(ngModel)]="dateN"></ion-datetime>
</ion-item>
set your date in this format YYYY/MM/DD HH:mm:ss for example 2019/08/05 09:35:07
Here is an example in your .ts file current = '2019/08/01 04:31:07'; // you can format your date to fit this
then in your html
<ion-datetime [(ngModel)]="current" displayFormat="YYYY/MM/DD HH:mm:ss" pickerFormat="YYYY/MM/DD HH:mm:ss"></ion-datetime>
displayFormat decides how you want the date-time to be displayed
I want to set min date and time to ion-datetime. But I am not able to set it without converting that to toISOString().
If I am converting to toISOString() then time is not setting the exact time. It is setting the 5.30 hr previous time.
<ion-datetime text-center placeholder="Start Date"
pickerFormat="MMM-DD-YYYY hh:mm A" displayFormat="MM-DD-YYYY hh:mm A" min="{{startDate}}"></ion-datetime>
startDate: any;
this.startDate = new Date().toISOString();
Can anyone please help me how to resolve this.
You can use the moment library for this and set max date like:
this.startDate = moment.utc(new Date()).local().format('YYYY-MM-DDTHH:mm:ss.SSS');
and ion-datetime does not compare time part.
I had been puzzled for a long time as my RadCartesianChart seems to reject to add a convert above on it's axis.
Here is what I had written:
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis Maximum="{x:BindViewModel.Infos.MaxmumDatetime}"
Minimum="{x:Bind ViewModel.Infos.MinmumDatetime}"
GapLength="0.5"
MajorStep="6"
MajorStepUnit="Hour"
LabelFormat="{}{0,0:HH:mm}"
x:Name="HorizontalAxis"
Title="Datetime of request"/>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis Title="Request Interval" x:Name="VerticalAxis">
</telerik:LinearAxis>
and data binding part:
<telerik:BarSeries ItemsSource="{x:Bind Path=ViewModel.Infos.Logs,Mode=TwoWay}" PaletteMode="Series">
<telerik:BarSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="requestTime" />
</telerik:BarSeries.ValueBinding>
<telerik:BarSeries.CategoryBinding>
<telerik:PropertyNameDataPointBinding PropertyName="createTime"/>
</telerik:BarSeries.CategoryBinding>
</telerik:BarSeries>
What should I do ??
I have a date field where the user is able to pick the date and time:
<ion-item>
<ion-label>Date</ion-label>
<ion-datetime displayFormat="DD MMM YYYY" [(ngModel)]="time" (ngModelChange)="onChange($event)" name = "time"></ion-datetime>
</ion-item>
<ion-item>
<ion-label>Time</ion-label>
<ion-datetime displayFormat="HH:mm" minuteValues="0,15,30,45" [(ngModel)]="time" (ngModelChange)="onChange($event)" name = "time"></ion-datetime>
</ion-item>
Similar to the above, I would like the user to be able to select the timezone by timezone offset (e.g. UTC+1:00).
How would I include timezone selection in a datetime picker? If this isn't possible, I'm happy to have a separate dropdown which in turn updates the "time" variable in the typescript (potentially using moment?).
The idea would be that this works similarly to Google Calendar, but just with offset as an option:
I'm receiving a date from a server in milliseconds since 1-1-1970. I then use the DateFormatter to print the date to the screen. However, Flex adds timedifference and thus it displays a different time than what I got from the server. I've fixed this by changing the date before printing to screen. But I think that's a bad solution because the date object doesn't hold the correct date.
Does anyone know how to use the dateFormatter to print the date, ignoring the timezone?
this is how I did it:
function getDateString(value:Date):String
{
var millisecondsPerMinute:int = 1000*60;
var newDate:Date = new Date(value.time - (millisecondsPerMinute*value.timezoneOffset));
var dateFormatter:DateFormatter = new DateFormatter();
dateFormatter.formatString = "EEEE DD-MM-YYYY LL:MM AA";
return dateFormatter.format(newDate);
}
Maybe there is something I'm missing but this seems to work for me.
<?xml version="1.0"?>
<!-- formatters\FormatterDateField.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<!-- Declare a DateFormatter and define formatting parameters.-->
<mx:DateFormatter id="dateFormatter"
formatString="EEEE DD-MM-YYYY LL:NN:SS AA"/>
<mx:Label text="Millis (1220836618601 == Monday 08-09-2008 01:16:58 AM):"/>
<mx:TextInput id="dob" text="1220836618601"/>
<mx:Label text="Formatted date UTC: "/>
<mx:TextInput id="formattedDate"
text=""
editable="false"/>
<mx:Label text="Formatted date local: "/>
<mx:TextInput id="formattedDateLoc"
text=""
editable="false"/>
<!-- Format and update the date.-->
<mx:Button label="Format Input"
click="
var d :Date = new Date(parseInt(dob.text));
formattedDate.text=dateFormatter.format(d.toUTCString());
formattedDateLoc.text=dateFormatter.format(d);
"/>
</mx:Application>
Suggesting that instead of passing the date object (which is timezone dependant) into the dateFormatter, pass in the date object's UTC String instead. I didn't find anything that would suggest that the DateFormatter does anything to the timezone, so there shouldn't be any need to try to compensate for the timezone, especially when the date object already provides a method for getting the UTC.
function getDateString(value:Date):String
{
var dateFormatter:DateFormatter = new DateFormatter();
dateFormatter.formatString = "EEEE DD-MM-YYYY LL:MM AA";
return dateFormatter.format(value.toUTCString());
}
In Flex Hero 4.5 you can use the new Spark DateTimeFormatter:
<s:DateTimeFormatter dateTimePattern="HH':'mm':'ss" id="dateFormatterUTC" useUTC="true" />
<s:Label text="{dateFormatterUTC.format(new Date())}" />
The most simple of fixes is to have as many objects as you can (and properties of objects) be strings. The timezoneOffset solution works fine, but the timezoneOffset for many US cities changes twice during the year. The best rule -- everything is a string.