![]()  | 
  
    The Hubzilla
    
   | 
 
Some functions for date and time related tasks. More...
Functions | |
| timezone_cmp ($a, $b) | |
| Two-level sort for timezones.  More... | |
| is_null_date ($s) | |
| get_timezones () | |
| Return timezones grouped (primarily) by continent.  More... | |
| datetime_convert ($from= 'UTC', $to= 'UTC', $s= 'now', $fmt="Y-m-d H:i:s") | |
| General purpose date parse/convert function.  More... | |
| dob ($dob) | |
| Wrapper for date selector, tailored for use in birthday fields.  More... | |
| datesel ($format, $min, $max, $default, $id= 'datepicker') | |
| Returns a date selector.  More... | |
| timesel ($format, $h, $m, $id='timepicker') | |
| Returns a time selector.  More... | |
| datetimesel ($format, $min, $max, $default, $label, $id= 'datetimepicker', $pickdate=true, $picktime=true, $minfrom= '', $maxfrom= '', $required=false, $first_day=0) | |
| Returns a datetime selector.  More... | |
| relative_date ($posted_date, $format=null) | |
| Returns a relative date string.  More... | |
| plural_dates ($k, $n) | |
| age ($dob, $owner_tz= '', $viewer_tz= '') | |
| Returns timezone correct age in years.  More... | |
| get_dim ($y, $m) | |
| Get days of a month in a given year.  More... | |
| get_first_dim ($y, $m) | |
| Returns the first day in month for a given month, year.  More... | |
| cal ($y=0, $m=0, $links=false, $class='') | |
| Output a calendar for the given month, year.  More... | |
| z_birthday ($dob, $tz, $format="Y-m-d H:i:s") | |
| Return the next birthday, converted from the owner's timezone to UTC.  More... | |
| update_birthdays () | |
| Create a birthday event for any connections with a birthday in the next 1-2 weeks.  More... | |
Some functions for date and time related tasks.
| age | ( | $dob, | |
$owner_tz = '',  | 
        |||
$viewer_tz = ''  | 
        |||
| ) | 
Returns timezone correct age in years.
Returns the age in years, given a date of birth, the timezone of the person whose date of birth is provided, and the timezone of the person viewing the result.
Why? Bear with me. Let's say I live in Mittagong, Australia, and my birthday is on New Year's. You live in San Bruno, California. When exactly are you going to see my age increase?
A: 5:00 AM Dec 31 San Bruno time. That's precisely when I start celebrating and become a year older. If you wish me happy birthday on January 1 (San Bruno time), you'll be a day late.
| string | $dob | Date of Birth | 
| string | $owner_tz | (optional) timezone of the person of interest | 
| string | $viewer_tz | (optional) timezone of the person viewing | 
Referenced by advanced_profile(), dob(), Zotlabs\Module\Directory\get(), local_dir_update(), and zotinfo().
| cal | ( | $y = 0,  | 
        |
$m = 0,  | 
        |||
$links = false,  | 
        |||
$class = ''  | 
        |||
| ) | 
Output a calendar for the given month, year.
If $links are provided (array), e.g. $links[12] => 'http://mylink' , date 12 will be linked appropriately. Today's date is also noted by altering td class. Months count from 1.
| number | $y | Year | 
| number | $m | Month | 
| string | $links | (default false) | 
| string | $class | 
Referenced by Zotlabs\Module\Cal\get(), and Zotlabs\Module\Events\get().
| datesel | ( | $format, | |
| $min, | |||
| $max, | |||
| $default, | |||
$id = 'datepicker'  | 
        |||
| ) | 
Returns a date selector.
| string | $format | format string, e.g. 'ymd' or 'mdy'. Not currently supported | 
| DateTime | $min | unix timestamp of minimum date | 
| DateTime | $max | unix timestap of maximum date | 
| DateTime | $default | unix timestamp of default date | 
| string | $id | id and name of datetimepicker (defaults to "datetimepicker") | 
| datetime_convert | ( | $from = 'UTC',  | 
        |
$to = 'UTC',  | 
        |||
$s = 'now',  | 
        |||
$fmt = "Y-m-d H:i:s"  | 
        |||
| ) | 
General purpose date parse/convert function.
| string | $from | source timezone | 
| string | $to | dest timezone | 
| string | $s | some parseable date/time string | 
| string | $fmt | output format recognised from php's DateTime class http://www.php.net/manual/en/datetime.format.php | 
Referenced by Zotlabs\Zot\DReport\__construct(), abook_toggle_flag(), advanced_profile(), age(), anon_identity_init(), api_attach_list(), api_channel_stream(), api_date(), api_network_stream(), Zotlabs\Lib\Apps\app_store(), Zotlabs\Lib\Apps\app_update(), atom_entry(), attach_delete(), attach_list_files(), attach_mkdir(), attach_store(), authenticate_success(), bb_to_markdown_share(), btlogger(), cal(), channel_export_items(), channel_remove(), check_cron_broken(), check_zotinfo(), Zotlabs\Lib\Cache\clear(), comments_are_now_closed(), dba_mysqli\connect(), dba_pdo\connect(), consume_feed(), conversation(), Zotlabs\Zot\Verify\create(), Zotlabs\Lib\Chatroom\create(), create_account(), create_conversation(), create_identity(), delete_item_lowlevel(), discover_by_url(), dlogger(), dob(), Zotlabs\Lib\Chatroom\enter(), ev_compare(), event_import_ical(), event_import_ical_task(), event_store_event(), filepath_macro(), first_post_date(), fix_system_urls(), format_event_html(), format_event_ical(), format_event_obj(), format_todo_ical(), Zotlabs\Module\Dreport\get(), Zotlabs\Module\Manage\get(), Zotlabs\Module\Pubstream\get(), Zotlabs\Module\Admin\Queue\get(), Zotlabs\Module\Like\get(), Zotlabs\Module\Display\get(), Zotlabs\Module\Search\get(), Zotlabs\Module\Dirsearch\get(), Zotlabs\Module\Connections\get(), Zotlabs\Module\Webpages\get(), Zotlabs\Module\Network\get(), Zotlabs\Module\Hq\get(), Zotlabs\Module\Cal\get(), Zotlabs\Module\Uexport\get(), Zotlabs\Module\Channel\get(), Zotlabs\Module\Chatsvc\get(), Zotlabs\Module\Settings\Tokens\get(), Zotlabs\Module\Invite\get(), Zotlabs\Module\Mail\get(), Zotlabs\Module\Events\get(), Zotlabs\Module\Profile_photo\get(), Zotlabs\Module\Profiles\get(), get_atom_elements(), get_feed_for(), get_first_dim(), get_item_elements(), get_mail_elements(), get_profile_elements(), get_public_feed(), Zotlabs\Lib\ThreadItem\get_template_data(), get_webpage_elements(), identity_export_year(), Zotlabs\Module\Import\import_account(), import_author_rss(), import_author_unknown(), import_author_zot(), import_directory_profile(), import_menus(), import_site(), import_webpage_element(), import_xchan(), Zotlabs\Module\Zotfeed\init(), Zotlabs\Module\Impel\init(), Zotlabs\Module\Thing\init(), Zotlabs\Module\Regdir\init(), Zotlabs\Module\Ping\init(), item_create_edit_activity(), item_store(), item_store_update(), items_fetch(), list_post_dates(), log_failed_login(), logger(), mail_store(), menu_add_item(), menu_create(), menu_del_item(), menu_edit(), menu_edit_item(), Zotlabs\Lib\Chatroom\message(), new_contact(), Zotlabs\Lib\NativeWikiPage\page_history(), parse_vobject(), poco_load(), Zotlabs\Module\Changeaddr\post(), Zotlabs\Module\Removeaccount\post(), Zotlabs\Module\Removeme\post(), Zotlabs\Module\Settings\Account\post(), Zotlabs\Module\Admin\Account_edit\post(), Zotlabs\Module\Settings\Tokens\post(), Zotlabs\Module\Settings\Channel\post(), Zotlabs\Module\Events\post(), Zotlabs\Module\Mail\post(), Zotlabs\Module\Getfile\post(), Zotlabs\Module\Prate\post(), Zotlabs\Module\Item\post(), Zotlabs\Module\Chatsvc\post(), Zotlabs\Module\Tasks\post(), Zotlabs\Module\Rate\post(), Zotlabs\Module\Profile_photo\post(), Zotlabs\Module\Connedit\post(), Zotlabs\Module\Profiles\post(), posted_dates(), process_rating_delivery(), prune_hub_reinstalls(), dba_mysql\q(), dba_postgres\q(), dba_mysqli\q(), dba_pdo\q(), queue_deliver(), queue_insert(), queue_set_delivered(), relative_date(), Zotlabs\Daemon\Cron_weekly\run(), Zotlabs\Daemon\Poller\run(), Zotlabs\Daemon\Cron_daily\run(), Zotlabs\Daemon\Cron\run(), Zotlabs\Daemon\Cronhooks\run(), Zotlabs\Daemon\Checksites\run(), Zotlabs\Daemon\Externals\run(), Zotlabs\Daemon\Onepoll\run(), Zotlabs\Daemon\Deliver\run(), Zotlabs\Daemon\Directory\run(), Zotlabs\Daemon\Notifier\run(), photo_driver\save(), Zotlabs\Lib\NativeWikiPage\save_page(), send_message(), send_reg_approval_email(), Zotlabs\Lib\Cache\set(), Zotlabs\Lib\LDSignatures\sign(), Zotlabs\Lib\Enotify\submit(), sync_apps(), sync_chatrooms(), sync_directories(), sync_files(), sync_locations(), sync_menus(), tag_deliver(), Zotlabs\Zot\DReport\update(), update_birthdays(), update_directory_entry(), update_hub_connected(), update_modtime(), update_queue_item(), update_r1141(), verify_email_address(), Zotlabs\Widget\Conversations\widget(), Zotlabs\Widget\Archive\widget(), xchan_store(), xchan_store_lowlevel(), z_birthday(), zot_feed(), zot_process_response(), and zot_refresh().
| datetimesel | ( | $format, | |
| $min, | |||
| $max, | |||
| $default, | |||
| $label, | |||
$id = 'datetimepicker',  | 
        |||
$pickdate = true,  | 
        |||
$picktime = true,  | 
        |||
$minfrom = '',  | 
        |||
$maxfrom = '',  | 
        |||
$required = false,  | 
        |||
$first_day = 0  | 
        |||
| ) | 
Returns a datetime selector.
| string | $format | format string, e.g. 'ymd' or 'mdy'. Not currently supported | 
| DateTime | $min | unix timestamp of minimum date | 
| DateTime | $max | unix timestap of maximum date | 
| DateTime | $default | unix timestamp of default date | 
| string | $label | |
| string | $id | id and name of datetimepicker (defaults to "datetimepicker") | 
| boolean | $pickdate | true to show date picker (default) | 
| boolean | $picktime | true to show time picker (default) | 
| DateTime | $minfrom | set minimum date from picker with id $minfrom (none by default) | 
| DateTime | $maxfrom | set maximum date from picker with id $maxfrom (none by default) | 
| boolean | $required | default false | 
| int | $first_day | (optional) default 0 | 
Referenced by datesel(), Zotlabs\Module\Events\get(), and timesel().
| dob | ( | $dob | ) | 
Wrapper for date selector, tailored for use in birthday fields.
| string | $dob | Date of Birth | 
Referenced by Zotlabs\Module\Profiles\get().
| get_dim | ( | $y, | |
| $m | |||
| ) | 
Get days of a month in a given year.
Returns number of days in the month of the given year. $m = 1 is 'January' to match human usage.
| int | $y | year | 
| int | $m | month (1=January, 12=December) | 
Referenced by cal(), Zotlabs\Module\Cal\get(), Zotlabs\Module\Events\get(), list_post_dates(), and posted_dates().
| get_first_dim | ( | $y, | |
| $m | |||
| ) | 
Returns the first day in month for a given month, year.
Months start at 1.
| int | $y | Year | 
| int | $m | Month (1=January, 12=December) | 
Referenced by cal().
| get_timezones | ( | ) | 
Return timezones grouped (primarily) by continent.
Referenced by Zotlabs\Module\Setup\get(), Zotlabs\Module\Events\get(), and Zotlabs\Module\Settings\Channel\get().
| is_null_date | ( | $s | ) | 
Referenced by datetime_convert(), and relative_date().
| plural_dates | ( | $k, | |
| $n | |||
| ) | 
Referenced by relative_date().
| relative_date | ( | $posted_date, | |
$format = null  | 
        |||
| ) | 
Returns a relative date string.
Implements "3 seconds ago" etc. Based on $posted_date, (UTC). Results relative to current timezone. Limited to range of timestamps.
| string | $posted_date | |
| string | $format | (optional) parsed with sprintf() %1$d %2$s ago, e.g. 22 hours ago, 1 minute ago  | 
Referenced by advanced_profile(), conversation(), Zotlabs\Lib\Enotify\format(), Zotlabs\Module\Notifications\get(), Zotlabs\Module\Notify\get(), Zotlabs\Module\Connedit\get(), get_poller_runtime(), Zotlabs\Lib\ThreadItem\get_template_data(), and Zotlabs\Module\Ping\init().
| timesel | ( | $format, | |
| $h, | |||
| $m, | |||
$id = 'timepicker'  | 
        |||
| ) | 
Returns a time selector.
| string | $format | format string, e.g. 'ymd' or 'mdy'. Not currently supported | 
| string | $h | already selected hour | 
| string | $m | already selected minute | 
| string | $id | id and name of datetimepicker (defaults to "timepicker") | 
| timezone_cmp | ( | $a, | |
| $b | |||
| ) | 
Two-level sort for timezones.
Can be used in usort() to sort timezones.
| string | $a | |
| string | $b | 
| update_birthdays | ( | ) | 
Create a birthday event for any connections with a birthday in the next 1-2 weeks.
Update the year so that we don't create another event until next year.
Referenced by Zotlabs\Daemon\Cron_daily\run().
| z_birthday | ( | $dob, | |
| $tz, | |||
$format = "Y-m-d H:i:s"  | 
        |||
| ) | 
Return the next birthday, converted from the owner's timezone to UTC.
This makes it globally portable. If the provided birthday lacks a month and or day, return an empty string. A missing year is acceptable.
| string | $dob | Date of Birth | 
| string | $tz | Timezone | 
| string | $format | 
Referenced by zotinfo().