I have been using the standard ISO date time format to insert into the full calender. When testing it, I was not able to enter the time into the calender even though the allDay field was set to false. The following is my php code.
$eventdt = date_format($eventdate,'c');
$eventet = date_format($eventend,'c');
$buildjson = array('id'=>"$eventtest",'title' => "$eventtest", 'start' => "$eventdt", 'end' => "$eventet", 'allDay' => 'false', 'backgroundColor' => "$eventc");
array_push($jsonArray, $buildjson);
echo json_encode($jsonArray);
and the output of this code is
[{"id":"106","title":"106","start":"2013-07-17T11:00:00+02:00","end":"2013-07-18T14:00:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"107","title":"107","start":"2013-07-19T10:45:00+02:00","end":"2013-07-20T14:15:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"108","title":"108","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"109","title":"109","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":"false","backgroundColor":"#D7DF01"}]
I saw that the datetime tag has an extra addition of +2:00 which is the local time zone. When I tried to insert the value manually within the script, the time is getting reflected on the calender
Manual insertion:
events: [ {
title: 'class5 meeting',
start: '2013-07-17T11:00:00',
end: '2013-07-18T14:00:00',
allDay: false,
backgroundColor: '#ff0000'
}
]
Is there any way that I can trim the date and send in the required values so that the values will be reflected?
Thanks in Advance!
I think the issue might be that the false value for the 'allDay' field in your PHP generated JSON is a String whereas FullCalendar is expecting a Bool.
Try changing $buildjson as follows:
$buildjson = array('id'=>"$eventtest",'title' => "$eventtest", 'start' => "$eventdt", 'end' => "$eventet", 'allDay' => false, 'backgroundColor' => "$eventc"); (note that falseis not surrounded in quotes)
Related
I am using a DateControl widget by Kartik in my Yii2-powered system. The widget correctly saves the time I've selected. However, when I tried to update the data, it just always shows "12:30" as the time and not the time from the database. I am still new to Yii2 and I there's not much information on the Internet regarding this issue. Thank you for the help!
Code for my form:
<?= $form->field($model, 'class_start_time')->widget(DateControl::classname(), [
'type'=>DateControl::FORMAT_TIME,
])
?>
<?= $form->field($model, 'class_end_time')->widget(DateControl::classname(), [
'type'=>DateControl::FORMAT_TIME,
])
?>
Code for the config:
'displaySettings' => [
Module::FORMAT_DATE => 'dd-MM-yyyy',
Module::FORMAT_TIME => 'HH:mm a',
Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss a',
],
// format settings for saving each date attribute (PHP format example)
'saveSettings' => [
Module::FORMAT_DATE => 'php:U', // saves as unix timestamp
Module::FORMAT_TIME => 'php:H:i:s',
Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
I found the solution. The displaySettings should be hh:mm a and not HH:mm a. There is a mismatch in the format which causes the display to be in error when the time is in PM (or greater than 12:00:00).
I'm just trying to make a Date element in a Form, but the date format is always "mm/dd/yyyy" no matter how I try to change it. I tried setting it up like this:
$this->add(array(
'name' => 'ct-start_date',
'options' => array(
'label' => 'Start Date',
'format'=>'Y-m-d'
),
'attributes' => array(
'class' => 'ct-date',
),
'type' => 'Zend\Form\Element\Date',
));
And displaying like this:
echo $this->formRow($form->get('ct-start_date'));
But it still comes out as "mm/dd/yyyy" even though when I do:
print_r($form->get('ct-start_date')->getFormat());
that comes out as "Y-m-d"! So I added this:
$this->get('ct-start_date')->setOptions(array('format'=>'Y-m-d'));
No change. Then I tried this:
$date = new Element\Date('ct-start_date');
$date
->setLabel('Start Date')
->setAttributes(array(
'class' => 'ct-date',
))
->setOptions(array(
'format' => 'Y-m-d'
));
$this->add($date);
Same thing! That's in Chrome. In Firefox it's just an empty text input. Maybe I should just fall back on jQuery.
The format option in the Date element doesn't affect the input or output format of dates within the element.
It is used by the element's getInputSpecification() method to determine the date format to be used with the validator.
Example:
$this->add(array(
'name' => 'ct-start_date',
'options' => array(
'label' => 'Start Date',
'format'=>'Y-m-d'
),
'attributes' => array(
'class' => 'ct-date',
),
'type' => 'Zend\Form\Element\Date',
));
//...
public function getInputFilter()
{
$filter = new InputFilter()
// add default filters and validators for the date element
// the date validator will automatically be set up to accept dates
// formatted according to your elemen's "format" option
$filter->add($this->get('ct-start-date')->getInputSpecification());
../
return $filter;
}
If you are going to populate the form element with a date value from the server side, it needs to be in the appropriate format (e.g. $element->setValue(date('Y-m-d', $date));)
On the client side, they will either need to type it in the appropriate format or the validator will return an error, or make sure whatever client side date input you are using puts it in the Y-m-d format.
I'm trying to get the Podio API (php-library) to return all tasks that have a due date withing a certain range. PodioTask::get_all() works fine, it returns all tasks (limited to 100). Of course that is not very useful so I add attributes as documented:
$tasks = PodioTask::get_all(array(
'org' => [my_organization_id],
'completed' => 'false',
'limit' => 100
)
);
Up until here behavior is still as expected. As soon as I attempt to add the due_date-attribute I get an error message saying Uncaught PodioBadRequestError: "The values are not in the right format" Request URL: http://api.podio.com/task/?org=[my_organization_id]&completed=false&due_date=&limit=100
I try to do it like this, which works fine for the filters on Podio items:
$tasks = PodioTask::get_all(array(
'org' => [my_organization_id],
'completed' => 'false',
'due_date' => array(
'from' => '2d',
'to' => '90d'
),
'limit' => 100
)
);
I tried replacing the from and to dates with absolute ones in the YYYY-MM-DD format (as a string, but also tried a DateTime-object), but I get the same error. I tried removing the array and just setting a single date (as a string and a DateTime object) and none of it works. I keep getting the message that the values are not in the right format. The documentation tells me the due_date-parameter is "The from and to date the task should be due between. For valid options see date filtering under the filter area." If I go there I end up with the documentation for filtering items and I am doing the exact same thing here as for items, which I can filter by date. (https://developers.podio.com/doc/tasks/get-tasks-77949)
It appears like the php-library expects a string, but the API needs the 'from' and 'to' properties.
Anyone got any ideas?
Try this
$attributes = array(
'org' => [my_organization_id],
'completed' => 'false',
'limit' => 100,
'due_date'=> $fromDate.'-'.$toDate
);
$tasks = PodioTask::get_all($attributes);
where $fromDate and $toDate are DateTime Objects.
I am looking for a way to edit a timestamp field without displaying the time to it. Right now we are using this code to edit the field:
echo $this->Form->input('Kongress.beginn', array('size' => false,
'dateFormat' => 'DMY', 'timeFormat' => '24'));
Is there a way to do the exact same thing, but without displaying the time?
If the goal is to be able to edit the field but to start with a blank value, you could use a different name for the field and update the value before calling the save() method.
view:
echo $this->Form->input('Kongress.beginn_new', array('size' => false,
'dateFormat' => 'DMY', 'timeFormat' => '24'));
controller:
$this->request->data['Kongress']['beginn'] = $this->request->data['Kongress']['beginn_new'];
$this->Kongress->save($this->request->data);
I'm running into issues sending data to my DynamoDB. I have no idea what the issue is because it appears the program runs correctly, however I don't seem to have any data in my DB. I was able to create tables using Amazons tutorial, but when I follow this tutorial, I get a failed response if I try and put ALL the items, and a false success when it's only one item, as nothing is updated in the db.
Here's the code, I'm curious specifically if anyone knows a means to debug these kinds of issues.
<?php
// If necessary, reference the sdk.class.php file.
// For example, the following line assumes the sdk.class.php file is
// in an sdk sub-directory relative to this file
require_once('includes/backend.php');
// Instantiate the class
$dynamodb = new AmazonDynamoDB();
####################################################################
# Setup some local variables for dates
$one_day_ago = date('Y-m-d H:i:s', strtotime("-1 days"));
$seven_days_ago = date('Y-m-d H:i:s', strtotime("-7 days"));
$fourteen_days_ago = date('Y-m-d H:i:s', strtotime("-14 days"));
$twenty_one_days_ago = date('Y-m-d H:i:s', strtotime("-21 days"));
####################################################################
# Adding data to the table
echo PHP_EOL . PHP_EOL;
echo "# Adding data to the table..." . PHP_EOL;
// Set up batch requests
$queue = new CFBatchRequest();
$queue->use_credentials($dynamodb->credentials);
// Add items to the batch
$dynamodb->batch($queue)->put_item(array(
'TableName' => 'ProductCatalog',
'Item' => array(
'Id' => array( AmazonDynamoDB::TYPE_NUMBER => '101' ), // Hash Key
'Title' => array( AmazonDynamoDB::TYPE_STRING => 'Book 101 Title' ),
'ISBN' => array( AmazonDynamoDB::TYPE_STRING => '111-1111111111' ),
'Authors' => array( AmazonDynamoDB::TYPE_ARRAY_OF_STRINGS => array('Author1') ),
'Price' => array( AmazonDynamoDB::TYPE_NUMBER => '2' ),
'Dimensions' => array( AmazonDynamoDB::TYPE_STRING => '8.5 x 11.0 x 0.5' ),
'PageCount' => array( AmazonDynamoDB::TYPE_NUMBER => '500' ),
'InPublication' => array( AmazonDynamoDB::TYPE_NUMBER => '1' ),
'ProductCategory' => array( AmazonDynamoDB::TYPE_STRING => 'Book' )
)
));
echo "Item put in <b>Reply</b>" . "<br/>";
// Execute the batch of requests in parallel
$responses = $dynamodb->batch($queue)->send();
// Check for success...
if ($responses->areOK())
{
echo "The data has been added to the table." . PHP_EOL;
}
else
{
utdump($responses);
}
Thank you for your time
Try setting your region explicitly, e.g. for EU you need to call:
$myDynamoDbObject->set_region('dynamodb.eu-west-1.amazonaws.com');
It might also be that you have two tables in different regions, your application work with one of them and you trying to read (or track with web console) another one because of different default regions applied.
If you're tracking number of items in the table, keep in mind that it is not a real time figure, it is only updated every 6 hours or so. So the way use can ensure your item is indeed written by trying to read it back immediately after you receive the "OK" response for your put request.