Set time for daterangepicker - daterangepicker

The daterangepicker plugin allows to set date using the setStartDate and setEndDate methods.Is there any method to set the time in the plugin.

There doesn't appear to a method to set only the time, and they don't mention it in the docs, but if you can set it using the setStartDate and setEndDate methods.
Those methods will accept a moment object, and if you are only setting date values when you call those methods, the time will default to 12:00 am. Setting a time on the moment object before passing it in will update the time in the daterangepicker. Their docs don't mention it, but the picker will update the time as well as the date if you are using the timePicker. This will also work when initializing the picker for the startDate and endDate values, as well as limiting the times for minDate and maxDate.
Note that if you set a maxDate without a defined time, it will default to 12:00 am which can cause issues if you're using the timePicker. For example, if I set a maxDate of 04/04/2017, the picker will let me choose that date, but it will not let me select a time on 04/04/2017 past 12:00am. To fix this, I used the moment library to set .hour(23) and .minutes(59) on the moment object I wanted to set the maxDate to. This allows users to select any hour or minute on 04/04/2017. The docs for setting times on moments can be found here: https://momentjs.com/docs/#/get-set/
It's not exactly what you asked but I'll provide the solution I used to get around a similar issue for changing values that don't have methods here in case anyone else needs it. I needed to dynamically change the maxDate, but there isn't a built in method to change it, only an option to set it when initializing the picker. In order to work around it, I removed the date range picker and reinitialized it on the same input with the updated options. If you need to remove the picker, the use:
$('#myInput').data('daterangepicker').remove();

Related

Google Classroom (PHP Client Services): Create CourseWork with Due Date but No set Due Time

I've been working on creating Google Classroom Classwork programmatically using the Google PHP api client services library. I am able to successfully create coursework, using: courses_courseWork->create, and passing a coursework object.
However, I can't seem to create a Course work object with a due date but no due time. Creating without a due date works fine, but if I just set a due date, it says that a due time object ( Google_Service_Classroom_TimeOfDay ) must also be sent. I've tried creating without setting hours / minutes / seconds / nanos, I've tried setting them to null, and I've tried unsetting the object properties after creating it.
When I look at a created ClassWork object (through the web interface, with no due date), the dueTime object property is just an empty array. I cannot for the life of me figure out how to pass that when creating with the API.
Thank you!
Your question is a little old, but in case someone else is having this issue, if you set a dueDate, you must also set a dueTime. This is a requirement from the API:
dueDate: object(Date):
Optional date, in UTC, that submissions for this course work are due.
This must be specified if dueTime is specified.
dueTime: object(TimeOfDay):
Optional time of day, in UTC, that submissions for this course work are due.
This must be specified if dueDate is specified.
See: https://developers.google.com/classroom/reference/rest/v1/courses.courseWork#CourseWorkState
Also, as noted, all create request dates and times should be converted to UTC. Depending on how your app is set up, this can quickly get a bit complicated...
It may be easiest to use a library like moment.js or luxon, etc. to manipulate the dates.
(I used moment.js, converted the moment datetime object to UTC, then converted the moment object .toArray, which I iterated through to create dueDate and dueTime objects for the request)

EWS Java SendInvitationsMode SendToNone

i dont understand a sence of SendInvitationsMode.SendToNone.
Msdn.microsoft.com shows, how appointment could be created with this
option:
https://msdn.microsoft.com/en-us/library/office/dd633661(v=exchg.80).aspx
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
appointment.save();
, i expect, that outlook shows me in my calender this appointment only on the date: 2016-12-12.
But outlook shows me some different days. Obviously start- and end-date will be ignored, when i'am not set this option, when i save appointment: SendInvitationsMode.SendToNone.
"SendToNone" means for me, that this appointment will not be send to something else.
SendToNone means if you have a Meeting that when you create the meeting appointment meeting invitations will not be sent when you call save.
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
What are you trying to achieve though? are you trying to create an All Day appointment ? https://msdn.microsoft.com/en-us/library/office/dn756538(v=exchg.150).aspx the thing to be careful of here is matching the timezone if you have users in different timezone.

Server time in Joomla

Do you know of any way to check the current time in Joomla considering the selected time zone in global configuration?
I have been looking in administrator settings but did not see any single word about the current time.
You can use the following code:
$date = new DateTime();
$config = JFactory::getConfig();
$date->setTimezone(new DateTimeZone($config->get('offset')));
This does two things. The first line creates a DateTimeobject based on the current server time and timezone. The following two lines get Joomla's global configuration and change the timezone of out date object to that timezone.
You can then format the date to whatever format you like by calling $date->format('Y-m-d H:i:s');. You can replace the format specifier by whatever you need, a reference of possible formatting options can be found here: http://www.php.net/manual/de/function.date.php

Create SharePoint IF function Workflow

I am trying to update the date in a column based on the information contained in another column. I know it will be an "IF" function, but I am not getting the formula correct.
I need to update the due date column by adding the time based from the frequency columnn(week, day, month, etc...) to the completion date column....please help!
I would not use the Designer inside Visual Studio to handle an If-Clause. Reason: I didn't figure out how to use this and from other things lieke the While-Activity I read that this is much slower than a coded one.
For some handsome looking I would add "CodeActivity" and link/ invoke my method to this. Inside this method you could use
string frequency = workflowProperties.Item["name of other column"].ToString();
string oldDate = workflowProperties.Item["name of updating column"].ToString();
DateTime newDate = Convert.ToDateTime(oldDate);
if (String.Equals(frequency, "weekly", StringComparison.OrdinalIgnoreCase))
{
<your code like:> workflowProperties.Item["name of updating column"] = newDate.AddDays(7);
}
else if (...)
or use switch (frequency){}
Remind that workflowProperties.Item refers everytime to selected Item. Because this is a global variable inside your workflow, you can access to it from every method. If you don't understand this example, be free to ask.
Shegit

Managing Timezone in magento

How to manage timezone in magento at the time of product creation, in frontend i am filtering products by time,but problem is that client wants to show products creation time depend on user's timezone ? for example i am adding a product in admin area it shows 12.21pm but at the same time customer viewing this product from other country it should displays current time according to user's time zone, how can we do that?
please help me to get out of this.
Thanks in advance.
Be more specific about how you are generating the date and how you wish it to be displayed...
Here is a general approach:
In your template code place a span with a class around your time values. These time strings can be formatted with lots of options including the timezone in your php code.
Place javascript where appropriate: either in the header (onload function), in the footer or inline with your view.phtml.
In your javascript use the Prototype library to iterate over the time spans, e.g.:
$$('yourdateclass').each(function() {
//
});
On each of those elements convert the time with Date.parse() to a date object. Then use getTimezoneOffset to account for the visitors location, add/subtract accordingly and then update the element inner html to your preferred way of showing the time/date.
It worked for me.
$session = Mage::getSingleton('customer/session');
$time_zone = $session->getCustomer()->getTimezone();
$timeoffset = Mage::getModel('core/date')->calculateOffset($time_zone);
$timeoffset = $timeoffset - Mage::getModel('core/date')->getGmtOffset($time_zone);

Resources