Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 10ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
c

calculation

Recently created Least recently created Recently updated Least recently updated

airikr / Calculate age

Last active 3 months ago calculation function php

Calculate the age of someone or something.

0 0 1
1 <?php
2
3 # Add the time for a more accurate calculation.
4 # The time format must be a string if it begins with a zero (0)
5
6 function age($year, $month, $day, $time = null) {
7 if(!is_numeric($year) OR !is_numeric($month) OR !is_numeric($day)) {
8 return 'XX';
9
10 } else {