Drupal Views outputting wronf date - Dec 31, 1969 - drupal

Issue: Drupal Views module only displays Wed Dec 31, 1969 for date fields
I have created a CCK content field type called field_gse_event_start_time. I also have several views displays that use this field - a calendar view, a table view, and a block view for the home page. I also have a themed node template for the event content type that this field belongs to.
The start time field requires a 'to' date as well as a from date. I have tried to change the type of the field_gse_event_start_time to date, datetime, and datestamp. In all cases the node display of the fields is correct, but any view displays Wed Dec 31, 1969.
I am sure this is due to some casting error or null, which adjusts to this pre-epoc value.
I just don't even know where to begin or how to fix.
Some config
Drupal core 6.26
ctools-6.x-1.8.tar
date-6.x-2.9.tar
views-6.x-2.16.tar

You probably know that the 1969 date is returned by date() when you pass it an invalid epoch time and you have a negative timezone offset. So, date() will default the invalid epoch to 1, and the timezone offset makes it pre-epoch.
Why this is happening in your Drupal view is probably because of a views field handler expecting the wrong format. What field type are you using for field_gse_event_start_time?

Related

drupal 8 views date range filter - 'is between' operator not inclusive for end date

I have an Event content type with a Date range field. I created a view of events and added an exposed filter for the Date Range field. I used the operator 'is between', so the user can enter a start date and end date to search between.
If the event starts on 1/1/11 at 9am and ends on 1/1/11 at 5pm, I want this event to show up when the user filters for events between 1/1/11 and 1/1/11.
But there are no results unless you change the end date to something greater than 1/1/11. I know this makes sense according to the 'is between' filter but I don't think it will be intuitive for users.
Can anyone help me with a way to make the end date inclusive, so it includes events on the end date specified??
I'm using the datetime_range module, and I've patched it with #60 at https://www.drupal.org/node/2786577 to enable date range filtering with views.
Thank you
I believe you're going to need the Views Date Filter Datetime Granularity Option patch (until it gets committed) as well as the change from The Views integration Datetime Range fields should extend the views integration for regular Datetime fields, which is now in Drupal core 8.6+.
For even better UX, see Exposed views date filter with offset not working as expected

create date formatted custom_meta field in wordpress admin

I have created a custom meta field to be used within a custom post type, that is to be the start time of a series of events. However, I would like to run my query_posts off of this value, but it is not formatted in date/time format, therefore '1:00pm' shows up in the list before '9:00am'. Is it possible to format this value in the db or at least prior to setting the 'meta_key' meta_value in my arguments for my query?
I've come across this problem a few times before. I'm going to use my most recent example because it sounds like it's along the same lines of what you're doing.
I had to create an event calendar using WordPress. In my custom post type, I had two fields: a start time and an end time. Instead of just using "1:00pm" as the start and end times, I also included the dates. This would allow for events that would last an entire weekend like a concert or a race.
What I'm getting at here, is once the user submitted that the event started on January 3, 2012 at 8:00 am and ended on January 3, 2012 at 10:00 am, I saved both of the variables using strtotime(). If you're not familiar with this function, you can read more about it here: http://us.php.net/manual/en/function.strtotime.php.
I also suggest using the datetime picker add-on for jQuery UI http://trentrichardson.com/examples/timepicker/.
I hope this helped. I know I was a little vague at times. If you need me to explain anything in more detail, don't be afraid to ask.

Drupal Date api, dates are displayed as one day earlier than the date entered

i'm not sure what is going wrong, but I created a Date field, and though it has been working fine, on March 12, 2012 and beyond all dates entered are retrieved one day earlier. The fields in the node edit display the correct date, but retrieving is the problem. I'm not sure if it is a timezone issue? Why March 12, 2012 and past that?
I have a feeling it has something to do with UTC and DST, but i dont know what to do. In the Date and Time settings I have it set as america/toronto which is what I want.
I just added the timezone when using the format_date function:
$date_start = format_date(strtotime($node->field_event_date[0][value]),$type='custom',$format='F j, Y',$timezone='America/Toronto');

Drupal 6: Date module and displaying only DATE value, without TIME

I'm a newbie drupal guy,
I use http://drupal.org/project/date module for my events date, but this module displays TIME as well as default, and I can't turn that off from configuration pages unless I'm a blind :/ is there any way to display only DATE value?
Appreciate helps!! thanks a lot!
You need to add a new date and time format that only specifies the date portion under Administer › Site configuration › Date and time › Formats › Add format (the relative path is /admin/settings/date-time/formats/add).
Here are a couple of popular date formats strings according to the PHP date format characters:
m/d/Y becomes 06/22/2010
l, F j, Y becomes Tuesday, June 22, 2010
You can either set one of the three default format types (i.e. long, medium, or short) to use your custom format or you can add a new format type. In either case, you would just need to specify the date field to use the format type that is set to your custom date format.
See Display multiple Date formats, along with Theme the Date and Example - Theme all-day events without a time for more information on this (while the last two links are targeting Drupal 5, they still apply for Drupal 6, AFAIK).

Month navigation sidebar in blog section?

I have a blog section in a drupal website, built with Views. I want to add a sidebar with month navigation (as in each mont is listed with the number of posts, etc). How can I do this, preferably with Views?
Drupal views can create views which allow you to select and list or summarise lists of nodes by various fields including the date related fields. You can do this by adding an argument, and then setting how the view behaves when no argument is supplied.
Are you looking for something along the following lines?
March 2010 (3)
February 2010 (12)
January 2010 (7)
... etc.
Create a view called Monthly Summary, and add an "argument" 'Node: Created year + month'.
Then use the options on the argument to select the 'action to take if argument is not present'. Select 'Summary, sorted descending' to create list with most recent month at top.
Watch out for sorting issues - this choice of how you sort the monthly summary in the argument settings will override the usual views sort order. This caught me out for a while.
Have you tried the Date/Calendar modules? Some more details about the Calendar module (from its project page):
This module will display any Views date field in calendar formats, including CCK date fields, node created or updated dates, etc. Switch between year, month, and day views. Back and next navigation is provided for all views. Lots of the Calendar functionality comes from the Date module, so any time you update the Calendar module you should be sure you also update to the latest version of the Date module at the same time.
See also Date iCal, a project that contains code and features needed to either import or export dates using iCal feeds. The functionality that used to be in the Calendar iCal module has been moved into that module.

Resources