We can also get the submitted datetime (e.g. 2009-11-06 07:03:41) using the following:
<?php
$DateOfRequest = date("Y-m-d H:i:s", strtotime($_REQUEST["DateOfRequest"]));
?>
Or another good example of getting DateTime:
<?php
$DateOfRequest = date("Y-m-d H:i:s", mktime($_REQUEST["Hour"],$_REQUEST["Min"],$_REQUEST
["Sec"],$_REQUEST["Month"],$_REQUEST["Day"],$_REQUEST["Year"]));
?>
Tarih ve Zaman
- Giriş
- Yapılandırma/Kurulum
- Öntanımlı Sabitler
- Desteklenen Zaman Dilimlerinin Listesi
- DateTime — DateTime sınıfı
- DateTime::add — Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
- DateTime::__construct — Returns new DateTime object
- DateTime::createFromFormat — Returns new DateTime object formatted according to the specified format
- DateTime::diff — Returns the difference between two DateTime objects
- DateTime::format — Returns date formatted according to given format
- DateTime::getLastErrors — Returns the warnings and errors
- DateTime::getOffset — Returns the daylight saving time offset
- DateTime::getTimestamp — Gets the Unix timestamp
- DateTime::getTimezone — Return time zone relative to given DateTime
- DateTime::modify — Alters the timestamp
- DateTime::__set_state — The __set_state handler
- DateTime::setDate — Sets the date
- DateTime::setISODate — Sets the ISO date
- DateTime::setTime — Sets the time
- DateTime::setTimestamp — Sets the date and time based on an Unix timestamp
- DateTime::setTimezone — Sets the time zone for the DateTime object
- DateTime::sub — Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
- DateTime::__wakeup — The __wakeup handler
- DateTimeZone — DateTimeZone sınıfı
- DateTimeZone::__construct — Yeni bir DateTimeZone nesnesi oluşturur
- DateTimeZone::getLocation — Zaman dilimi konum bilgisini döndürür
- DateTimeZone::getName — Zaman diliminin adını döndürür
- DateTimeZone::getOffset — Returns the timezone offset from GMT
- DateTimeZone::getTransitions — Returns all transitions for the timezone
- DateTimeZone::listAbbreviations — Returns associative array containing dst, offset and the timezone name
- DateTimeZone::listIdentifiers — Returns numerically index array with all timezone identifiers
- DateInterval — DateInterval sınıfı
- DateInterval::__construct — Yeni bir DateInterval nesnesi oluşturur
- DateInterval::createFromDateString — Dizgenin göreli kısımlarından bir DateInterval nesnesi döndürür
- DateInterval::format — Zaman aralığını biçimler
- DatePeriod — DatePeriod sınıfı
- DatePeriod::__construct — Yeni bir DatePeriod nesnesi oluşturur
- Tarih ve Zaman İşlevleri
- checkdate — Miladi tarihi doğrular
- date_add — DateTime::add işlevinin takma adıdır
- date_create_from_format — DateTime::createFromFormat işlevinin takma adıdır
- date_create — Yeni bir DateTime nesnesi döndürür
- date_date_set — DateTime::setDate işlevinin takma adıdır
- date_default_timezone_get — Betik içerisindeki tüm tarih/zaman işlevleri tarafından kullanılan öntanımlı zaman dilimini getirir
- date_default_timezone_set — Betik içerisindeki tüm tarih/zaman işlevleri tarafından kullanılan öntanımlı zaman dilimini ayarlar
- date_diff — DateTime::diff işlevinin takma adıdır
- date_format — DateTime::format işlevinin takma adıdır
- date_get_last_errors — DateTime::getLastErrors işlevinin takma adıdır
- date_interval_create_from_date_string — DateInterval::createFromDateString işlevinin takma adıdır
- date_interval_format — DateInterval::format işlevinin takma adıdır
- date_isodate_set — DateTime::setISODate işlevinin takma adıdır
- date_modify — DateTime::modify işlevinin takma adıdır
- date_offset_get — DateTime::getOffset işlevinin takma adıdır
- date_parse_from_format — Get info about given date
- date_parse — Verilen tarih hakkındaki ayrıntılı bilgiyi ilişkisel dizi olarak döndürür
- date_sub — DateTime::sub işlevinin takma adıdır
- date_sun_info — Güneşin doğuşu/batışı ve alacakaranlık başlangıcı/sonu hakkında bilgi içeren bir dizi döndürür
- date_sunrise — Belirtilen gün ve konum için şafak zamanını döndürür
- date_sunset — Verilen gün ve konum için günbatımı zamanını döndürür
- date_time_set — DateTime::setTime işlevinin takma adıdır
- date_timestamp_get — DateTime::getTimestamp işlevinin takma adıdır
- date_timestamp_set — DateTime::setTimestamp işlevinin takma adıdır
- date_timezone_get — DateTime::getTimezone işlevinin takma adıdır
- date_timezone_set — DateTime::setTimezone işlevinin takma adıdır
- date — Yerel tarihi/saati biçimlendirir
- getdate — Tarih/zaman bilgisi getirir
- gettimeofday — Geçerli zamanı getirir
- gmdate — Bir tarih/saati GMT/UTC tarih/saati olarak biçemler
- gmmktime — Bir GMT tarihi için Unix zaman damgasını döndürür
- gmstrftime — Yerel ayarlara göre tarih ve saati, GMT/UTC türüne çevirir
- idate — Yerel zamanı/tarihi tamsayı olarak biçimlendirir
- localtime — Yerel zamanı getirir
- microtime — Geçerli Unix zaman damgasını mikrosaniye olarak döndürür
- mktime — Bir tarih için Unix zaman damgasını döndürür
- strftime — Format a local time/date according to locale settings
- strptime — strftime işleviyle üretilen zaman ve tarihleri çözümler
- strtotime — Parse about any English textual datetime description into a Unix timestamp
- time — Geçerli Unix zaman damgasını döndürür
- timezone_abbreviations_list — DateTimeZone::listAbbreviations işlevinin takma adıdır
- timezone_identifiers_list — DateTimeZone::listIdentifiers işlevinin takma adıdır
- timezone_location_get — DateTimeZone::getLocation işlevinin takma adıdır
- timezone_name_from_abbr — Kısaltmasından, zaman diliminin adını döndürür
- timezone_name_get — DateTimeZone::getName işlevinin takma adıdır
- timezone_offset_get — DateTimeZone::getOffset işlevinin takma adıdır
- timezone_open — Yeni bir DateTimeZone nesnesi döndürür
- timezone_transitions_get — DateTimeZone::getTransitions işlevinin takma adıdır
- timezone_version_get — Gets the version of the timezonedb
Tarih ve Zaman
kapoor_rajiv at hotmail dot com
12-Oct-2009 11:59
12-Oct-2009 11:59
zoe at monkeehouse dot com
24-Oct-2008 10:52
24-Oct-2008 10:52
Should you want to convert between HH:MM:SS and plain seconds like in MySQL, these functions should do the trick:
<?php
function time_to_sec($time) {
$hours = substr($time, 0, -6);
$minutes = substr($time, -5, 2);
$seconds = substr($time, -2);
return $hours * 3600 + $minutes * 60 + $seconds;
}
function sec_to_time($seconds) {
$hours = floor($seconds / 3600);
$minutes = floor($seconds % 3600 / 60);
$seconds = $seconds % 60;
return sprintf("%d:%02d:%02d", $hours, $minutes, $seconds);
}
?>
