Php date format online

Timestamp To Date Converter

Timestamp Online is timestamp converver between unix timestamp and human readable form date. If you want to convert timestamp, it is sufficient to either enter your timestamp into input area, or you can construct URL with your timestamp — http://timestamp.online/timestamp/ .

Timestamp Online also supports countdown, so you can see, how much time remains to particular timestamp. URLs for countdowns have following form — http://timestamp.online/countdown/ .

Current Timestamp Examples

These examples are showing how to get current unix timestamp in seconds. These examples are returning timestamp in seconds, although some of the languages are returning timestamp in milliseconds.

long ts = System.currentTimeMillis()/1000;

Current Date and Time Examples

These examples are showing how to get current date and time that could be presented to the end-user.

import datetime; datetime.datetime.now().isoformat()

Timestamp to Date Examples

These examples are showing how to convert timestamp — either in milliseconds or seconds to human readable form.

new Date(1688807387000).toLocaleString();
import datetime datetime.datetime.fromtimestamp(1688807387).isoformat()
import Java.Util.Date; import java.text.SimpleDateFormat; Date currentDate = new Date (1688807387000) SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss") String date = dateFormat.format(currentDate);
date +"%Y-%m-%d %H:%M:%S" -d @1688807387

Parse Date to Timestamp Examples

These examples are showing how to parse date in human readable form to unix timestamp in either milliseconds or seconds.

Date.parse("2023-07-08 11:09:47")/1000;
import time int(time.mktime(time.strptime("2023-07-08 11:09:47"))) - time.timezone
import java.text.SimpleDateFormat; SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss") long ts = dateFormat.parse(2023-07-08 11:09:47).getTime()/1000;

Unix Time

Unix time (also known as POSIX time or Epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds. It is used widely in Unix-like and many other operating systems and file formats. Because it does not handle leap seconds, it is neither a linear representation of time nor a true representation of UTC.

Читайте также:  Замена типов данных python

Источник

date

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time.

Parameters

Format accepted by DateTimeInterface::format.

The optional timestamp parameter is an int Unix timestamp that defaults to the current local time if timestamp is omitted or null . In other words, it defaults to the value of time.

Return Values

Returns a formatted date string. If a non-numeric value is used for timestamp , false is returned and an E_WARNING level error is emitted.

Exceptions and Errors

Every call to a date/time function will generate a E_WARNING if the time zone is not valid. See also date_default_timezone_set

Notes

Note:

To generate a timestamp from a string representation of the date, you may be able to use strtotime. Additionally, some databases have functions to convert their date formats into timestamps (such as MySQL’s UNIX_TIMESTAMP function).

Timestamp of the start of the request is available in $_SERVER[‘REQUEST_TIME’] .

Changelog

Version Description
8.0.0 timestamp is nullable now.
  • getdate — Get date/time information
  • getlastmod — Gets time of last page modification
  • gmdate — Format a GMT/UTC date/time
  • idate — Format a local time/date as integer
  • mktime — Get Unix timestamp for a date
  • time — Return current Unix timestamp
  • DateTimeImmutable::__construct — Returns new DateTimeImmutable object

Example of date

Function date:

Date and Time Functions

  • checkdate
  • date_add
  • date_create_from_format
  • date_create_immutable_from_format
  • date_create_immutable
  • date_create
  • date_date_set
  • date_default_timezone_get
  • date_default_timezone_set
  • date_diff
  • date_format
  • date_get_last_errors
  • date_interval_create_from_date_string
  • date_interval_format
  • date_isodate_set
  • date_modify
  • date_offset_get
  • date_parse_from_format
  • date_parse
  • date_sub
  • date_sun_info
  • date_sunrise
  • date_sunset
  • date_time_set
  • date_timestamp_get
  • date_timestamp_set
  • date_timezone_get
  • date_timezone_set
  • date
  • getdate
  • gettimeofday
  • gmdate
  • gmmktime
  • gmstrftime
  • idate
  • localtime
  • microtime
  • mktime
  • strftime
  • strptime
  • strtotime
  • time
  • timezone_abbreviations_list
  • timezone_identifiers_list
  • timezone_location_get
  • timezone_name_from_abbr
  • timezone_name_get
  • timezone_offset_get
  • timezone_open
  • timezone_transitions_get
  • timezone_version_get
  • DateInterval::__construct
  • DateInterval::createFromDateString
  • DateInterval::format
  • DatePeriod::__construct
  • DatePeriod::getDateInterval
  • DatePeriod::getEndDate
  • DatePeriod::getRecurrences
  • DatePeriod::getStartDate
  • DateTime::add
  • DateTime::__construct
  • DateTime::createFromFormat
  • DateTime::createFromImmutable
  • DateTime::createFromInterface
  • DateTime::diff
  • DateTime::format
  • DateTime::getLastErrors
  • DateTime::getOffset
  • DateTime::getTimestamp
  • DateTime::getTimezone
  • DateTimeImmutable::add
  • DateTimeImmutable::__construct
  • DateTimeImmutable::createFromFormat
  • DateTimeImmutable::createFromInterface
  • DateTimeImmutable::createFromMutable
  • DateTimeImmutable::getLastErrors
  • DateTimeImmutable::modify
  • DateTimeImmutable::setDate
  • DateTimeImmutable::setISODate
  • DateTimeImmutable::__set_state
  • DateTimeImmutable::setTimestamp
  • DateTimeImmutable::setTime
  • DateTimeImmutable::setTimezone
  • DateTimeImmutable::sub
  • DateTime::modify
  • DateTime::setDate
  • DateTime::setISODate
  • DateTime::__set_state
  • DateTime::setTimestamp
  • DateTime::setTime
  • DateTime::setTimezone
  • DateTime::sub
  • DateTime::__wakeup
  • DateTimeZone::__construct
  • DateTimeZone::getLocation
  • DateTimeZone::getName
  • DateTimeZone::getOffset
  • DateTimeZone::getTransitions
  • DateTimeZone::listAbbreviations
  • DateTimeZone::listIdentifiers

Most used PHP functions

  • sandbox (118364010)
  • preg_replace (206872)
  • json_encode (145680)
  • preg_match (135042)
  • unserialize (115699)
  • serialize (111296)
  • hex2bin (100964)
  • uniqid (82078)
  • array (72436)
  • json_decode (61733)
  • iconv (54019)
  • utf8_decode (47290)
  • preg_replace_callback (47044)
  • preg_match_all (45922)
  • str_replace (42721)
  • strtotime (38824)

Источник

date() – форматирование даты PHP

date($format, $timestamp) – форматирует дату/время по шаблону, где:

Результат работы функции зависит от настроек часового пояса, установить его можно следующем образом:

Основные параметры шаблона

Символ Описание Пример возвращаемого значения
День
j День месяца без ведущего нуля от 1 до 31
d День месяца, 2 цифры с ведущим нулём от 01 до 31
l Полное наименование дня недели от Sunday до Saturday
D День недели, 3 символа от Mon до Sun
z Порядковый номер дня в году От 0 до 365
Неделя
N Порядковый номер дня недели от 1 (понедельник)
до 7 (воскресенье)
W Порядковый номер недели года Например: 42 (42-я неделя года)
Месяц
n Порядковый номер месяца без ведущего нуля от 1 до 12
m Порядковый номер месяца с ведущим нулём от 01 до 12
F Полное название месяца от January до December
M Сокращенное наименование месяца, 3 символа от Jan до Dec
t Количество дней в месяце от 28 до 31
Год
Y Год, 4 цифры 2019
y Год, 2 цифры 19
Время
g Часы в 12-часовом формате без ведущего нуля от 1 до 12
h Часы в 12-часовом формате с ведущим нулём от 01 до 12
G Часы в 24-часовом формате без ведущего нуля от 0 до 23
H Часы в 24-часовом формате с ведущим нулём от 00 до 23
i Минуты с ведущим нулём от 00 до 59
s Секунды с ведущим нулём от 00 до 59
v Миллисекунды 123
Полная дата/время
c Дата в формате ISO 8601 2004-02-12T15:19:21+00:00
r Дата в формате RFC 2822 Thu, 21 Dec 2000 16:01:07 +0200

дд.мм.ггг (dd.mm.yyyy)

Самый распространенные форматы: dd.mm.yyyy и dd.mm.yyyy hh:ss .

echo date('d.m.Y'); // 19.07.2023 echo date('d.m.Y H:i'); // 19.07.2023 09:39 echo date('d.m.Y H:i:s'); // 19.07.2023 09:39:49

гггг-мм-дд (yyyy.mm.dd)

Используется в MySQL тип поля DATE.

Источник

Оцените статью