Arabic StrToTime:

Parse about any Arabic textual datetime description into a Unix timestamp.

The function expects to be given a string containing an Arabic date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if none is supplied.


Example Output:

Friday 15th August 2025

الخميس القادم - 1755734400 - Thursday 21st August 2025

الأحد الماضي - 1754784000 - Sunday 10th August 2025

بعد أسبوع و ثلاثة أيام - 1756161634 - Monday 25th August 2025

منذ تسعة أيام - 1754520034 - Wednesday 06th August 2025

قبل إسبوعين - 1754088034 - Friday 01st August 2025

2 آب 1975 - 176169600 - Saturday 02nd August 1975

1 رمضان 1429 - 1220227200 - Monday 01st September 2008


Example Code:

<?php
    date_default_timezone_set
('UTC');
    
$time time();

    echo 
date('l dS F Y'$time);
    echo 
'<br /><br />';

    
$Arabic = new \ArPHP\I18N\Arabic();

    
$str  'الخميس القادم';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";
    
    
$str  'الأحد الماضي';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";
    
    
$str  'بعد أسبوع و ثلاثة أيام';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";
    
    
$str  'منذ تسعة أيام';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";
    
    
$str  'قبل إسبوعين';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";
    
    
$str  '2 آب 1975';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";

    
$str  '1 رمضان 1429';
    
$int  $Arabic->strtotime($str$time);
    
$date date('l dS F Y'$int);
    echo 
"$str - $int - $date<br /><br />";