Bitrix Site Manager

MakeTimeStamp

int
MakeTimeStamp(
 string datetime,
 string format = FORMAT_DATETIME
)

The function MakeTimeStamp converts the time to the Unix format.

Parameters

ParameterDescription
datetime Time to convert.
format_type Format of the time in which the datetime is specified. The following specifies are possible:
  • YYYY - year;
  • MM - month;
  • DD - day;
  • HH - hours;
  • MI - minutes;
  • SS - seconds.
Optional. By default, the FORMAT_DATETIME constant value is used, which stores the time format of the site (or language for the administrative section).

See Also

Example



<?
// set date
$date = "07.04.2005 11:32:00";

// convert to Unix-timestamp
if ($stmp = MakeTimeStamp($date, "DD.MM.YYYY HH:MI:SS"))
{
	// print the same date obtained 
         // from Unix-timestamp
	echo date("d.m.Y H:i:s", $stmp);
}
else // if false returned...
{
	// print error msg
	echo "Date is incorrect!";
}
?>
<?
// print the date of information block activity
// in arbitrary format

// include the module
if (CModule::IncludeModule("iblock"))
{
    // select an element
    $rsElement = CIBlockElement::GetByID(32675);
    $arElement = $rsElement->Fetch();

    // obtain the activity date
    // in the current site format
    $date_active = $arElement["ACTIVE_FROM"]; // 28.01.2005
    
    // get the current site format
    $site_format = CSite::GetDateFormat(); // DD.MM.YYYY HH:MI:SS

    // convert to Unix format
    if ($stmp = MakeTimeStamp($date_active, $site_format))
    {
        // print the element activity date
        // in arbitrary format
        // using the PHP date function
        echo date("d F Y", $stmp); // 28 January 2005
    }
    else // failed
    {
        // print error msg
        ShowError("Date of element 32675 is incorrect!");
    }
}
?>