if the time in mysql is set to '2011-08-07 08:00:00', the value of dijit.form.TimeTextBox will be showed like this '2011-08-07 16:00:00'. The diffence of time between mysql and web is 8 hours,so i think the default value of zone in dojo is set to 'UTC'(not 'BEIJING'). Who can tell me how to deal with it?
I am wishing your help,thanks!
this should help you http://dojotoolkit.org/reference-guide/1.9/dojo/date/locale/format.html#dojo-date-locale-format
After you get the data from server, format it with your desired locale and add it as a value on the textbox
Related
I'm making an app with laravel, this features a calendar. I'm using "fullcalendar" which is very restricting on date format and AFAIK only accepts 'yyyy/mm/dd'. I'm using the jQuery datepicker and have edited the formatting to make it work. That all works fine and on the insert for a long time I would never get this error, however suddenly it's started giving me this error after days of not having it. I really don't understand. Unless there's a way to change fullcalendar formatting to match the accepted formatting for SQL, which has not affected my app since now, then I'd love to hear it.
(error: QLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '05/14/2020' for column)
Thanks.
fixed it, my formatter was broken
I'll have to save various working hours (open and closes) and wonder what is the best format/way to use ?
Sure I can choose to have time time as DB type for these values and format the DB time like that:
Time.current.to_s(:time)
=> "15:52"
Instead of Time.current I'll be select the corresponding time value from the DB:
Thu, 12 Apr 2018 15:48:28 UTC +00:00
But what is solution to choose for a User to enter time values in the front-end ? Moreover, I'll have to either choose a general format for hours, like
07:30
Or (it the requirement changes) enable a locale-dependent format like this:
7ч30 (for Russia)
7h30 (for France)
etc..
Any ideas and tips ? Thank you.
I'd store "seconds from midnight", so 15:52 would be stored as the integer 57120. Then I'd write a custom type see the attribute docs for more details that converts to/from that integer.
Then I'd just have different formats in the locale file that I'd use for that conversion.
Here is the problem.
I have to create a submission form on my Yii-based website. The form requires to enter a datetime range.For that I am using "jui datetimepicker" third-party Yii extension.
http://www.yiiframework.com/extension/datetimepicker/
I use two date fields with this extension pertaining to start and end time respectively. So, what I want to achieve is be able to restrict the start datetime only to time in the future (neither past dates nor time should be selected) and the end time itself should be restricted to the maximum of three hours following the start time.
EXAMPLE: a user wants to schedule an event. They choose a date and time, which are of course in the future. Let's say they choose March 15, 13 O'clock as the start time in the start time field. Once they are done and move to the next field ("end time"), the respective datetimepicker restricts the range of time from March 15, 13:00 to March 15, 16:00.
Hence the second datetimepicker should be dynamically updated depending on the input of the first one.
It's possible o specify date range in the datetimepicker starting from the current date, but there is nothing like that for the time selection, so a user still can select time which has already passed.
It's not that I want to solve this problem with this extention, if anybody has any suggestions about YII solutions allowing to specify a datetime range in the most clean and effective way - it would be much appreciated.
You should use the edaterangepicker extension instead.
Given the API for the jquery timepicker addon. you should add the following to your widget call (along side 'model','attribute', etc)
'options'=>array(
'minDateTime'=>'<start dateTime here>',
'onSelect'=>'<JS function to run>'
)
The function you run on the "onSelect" event should dynamically set the minDateTime for the second dateTime input field, for ex:
function (selectedDateTime){
<EndDatePickerElement>.datetimepicker('option', 'minDateTime', <start dateTime here using selectedDateTime> );
}
There are more examples on the link provided earlier if you need to make it even more precise (like say if you wanted the starting date to be pushed back by the amount of time the user was on the page rather than it being set when the page was loaded. etc...)
How can i check the system date format? Tried with the code below, but when i change my system's date format to another date format to test the code, it's still showing the date format before changed!
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern()
Ok. I managed to find the solution, the 'CurrentCulture' has to be 'CurrentUICulture', instead of CurrentCulture. Which is as below:
System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern()
This will work in US regional settings
table.Select("[Date] = "#04/16/1984#"
This should work in german regional settgins but it thorws dateformat excpetion
table.Select("[Date] = "#16.04.1984#"
To me it seems that datatable does not understand current regional settings. Is there a way to pass date in a certian format, so it will work in any regional setting?
To use Dates with DataTable.Select, you need use InvariantCulture Format and enclose it with #
At Debug:
? TD.Select ("fisap=#9/25/2011 00:00#").Length
20
? TD.Select ("fisap=#9.25.2011 00:00#")(0)(10).ToString
"25/09/2011 0:00:00" - (Spanish)
? TD.Select ("fisap=#9/25/2011 00:00#")(0)(10)
#9/25/2011# {Date}
I guess it depends on the underlying datastore date and time settings, as it is it that stores the information. So, if you're client application is in another regional settings format, make sure to format your date string into the right database settings.
I think this should be helpful: DateTime.Parse Method (String)