LLMS_Post_Model::get_date( string $key, string $format = null )

Getter for date strings with optional date format conversion

Description Description

If no format is supplied, the default format available via $this->get_date_format() will be used.

Top ↑

Parameters Parameters


(string) (Required) Property key.


(string) (Optional) Any valid date format that can be passed to date().

Default value: null

Top ↑

Return Return


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	public function get_date( $key, $format = null ) {
		$format = ( ! $format ) ? $this->get_date_format() : $format;
		$raw    = $this->get( $key );
		// Only convert the date if we actually have something stored, otherwise we'll return the current date, which we probably aren't expecting.
		$date = $raw ? date_i18n( $format, strtotime( $raw ) ) : '';

		 * Filters the date(s)
		 * The first dynamic portion of this hook, `$this->model_post_type`, refers to the model's post type. For example "course",
		 * "lesson", "membership", etc...
		 * The second dynamic part of this hook, `$key`, refers to the date property name.
		 * @since 3.0.0
		 * @param string          $date      The formatted date.
		 * @param LLMS_Post_Model $llms_post The LLMS_Post_Model instance.
		return apply_filters( "llms_get_{$this->model_post_type}_{$key}_date", $date, $this );

Top ↑

Changelog Changelog

Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.