How can I properly render exclusively end date from the Drupal 7 Date field in template file?
$node->field_start_date[LANGUAGE_NONE][0]` (is it correct?)
I can get to raw values but I want it to get formatted etc.
You can use the code below:
drupal_render(field_view_field('node', $node, 'field_end_datetime'));
field_view_field: https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_field/7
Related
I use Redux Form and react-datepicker
It works very nice, and I would like to get it work ideally according to my needs.
I need to show the date in localized format (let's say DD/MM/YYYY), and in the same time save value attribute of the input in static format ("YYYY-MM-DD").
I could add a hidden input with such value format, but if it's possible to avoid it using datepicker customization, it would be great!
Thanks for your advice in advance.
UPD:
Take a look on screenshots:
This is how it works now (nothing has to be changed here).
And value is synchronized with the locale. I want to keep the locale to present my date in the locale format for the user, and keep the format unchanged ("YYYY-MM-DD" forever) for the back end.
Here is the link to codesandbox.
You can use state and moment.js package to have date in several formats.
EDIT: the key thing is redux form. Datepicker is just view that can show exactly what you need. So, what you can do is: change redux form field value (or what you are using) and just have another state field (let's say 'dateForDatepicker') which value you'll pass to datepicker.
GOOD SOLUTION: https://stackoverflow.com/a/42726079/7479959
I am using angular DateTime Picker. i am using $uibModel to show a pop up and couple of fields are there for updatind data. I am using
bootstrap-ui-datetime-picker
this date to add atetime picker. I am passing JSON and I am displaying in corresponding fields. My date format is
2016-02-19T10:55:33+00:00
and My format I am using in input field is
datetime-picker="yyyy-MM-ddTHH:mm:ss:sssZ"
as per the docs. But I am not getting the model reflected in the text box. If I remove the format in input field I get the model displayed there. Why is this happening? i have given the same format as the value to format input. Thanks.
I'm trying to implement a feature for a form where:
1. I display a date string in the format mm-dd-yyyy
2. User is allowed to edit the form, and the date string would remain in the format mm-dd-yyyy
3. When the user submits the form, the date string must be in the format yyyy-mm-dd.
3. The original format of the date string is yyyy-mm-dd.
I would prefer to achieve this somehow by means of a directive rather than calling a function everytime a user submits a form, was wondering if there were any thoughts on a good way to do this?
I've given angular-ui-mask a look but am not sure if this would help me so much for this case.
Thanks!
I need to set the kendo angular datepicker input field to a date value with a particular date format when my angular model is holding a string date value like "2014-08-21T11:27:04". can anyone please help?
You can use a date filter to change the model with defined date/time format in JavaScript or in HTML templates.
There is a lot of elements which can be used to compose a date string, so visit the official docs, where everything is well described.
In Drupal 7, I have an Event content type. When saved, I want it's URL to be /calendar/day/{yyyy-mm-dd}/{title}, where {yyyy-mm-dd} is based on field_event_date. The Token module can do this for create & change date fields, but not for a custom field I created, called field_event_date. So, to compensate, I want to create a computed field called field_event_date_Ymd, which stores the yyyy-mm-dd format from field_event_date, so that I can reference it in the URL pattern.
I'm not a PHP programmer, so can someone help me with the code for this? Is it something like this?
$entity_field[0]['value'] = $field_event_date->format('Y-m-d');
$entity_field[0]['value'] = $field_event_date->format('Y-m-d');