फाइल सिस्टम ext4
है (और अधिक हाल Unixes पर आम/Ubuntu की तरह Linuxes) या ntfs
(विंडोज़), तो mtime
उप दूसरा परिशुद्धता करता है।
यदि फ़ाइल सिस्टम ext3
(या शायद अन्य; यह कुछ समय पहले मानक था और अभी भी आरएचईएल द्वारा उपयोग किया जाता है), तो mtime
केवल निकटतम दूसरे में संग्रहीत है। शायद वह पुराना डिफ़ॉल्ट है क्यों PHP निकटतम दूसरे स्थान पर केवल mtime
का समर्थन करता है।
PHP में मान लाने के लिए, आपको बाहरी उपयोग को कॉल करने की आवश्यकता है, क्योंकि PHP स्वयं इसका समर्थन नहीं करता है।
(मैंने केवल अंग्रेजी लोकेल के साथ सिस्टम पर निम्न परीक्षण किया है; stat
का "मानव पठनीय" आउटपुट भिन्न हो सकता है, या strtotime
व्यवहार गैर-अंग्रेजी लोकेशंस पर भिन्न हो सकता है। इसे किसी भी समय क्षेत्र में ठीक काम करना चाहिए, stat
के उत्पादन में एक समयक्षेत्र विनिर्देशक जो strtotime
द्वारा सम्मानित किया है भी शामिल है के रूप में)
class FileModTimeHelper
{
/**
* Returns the file mtime for the specified file, in the format returned by microtime()
*
* On file systems which do not support sub-second mtime precision (such as ext3), the value
* will be rounded to the nearest second.
*
* There must be a posix standard "stat" on your path (e.g. on unix or Windows with Cygwin)
*
* @param $filename string the name of the file
* @return string like microtime()
*/
public static function getFileModMicrotime($filename)
{
$stat = `stat --format=%y $filename`;
$patt = '/^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)\.(\d+) (.*)$/';
if (!preg_match($patt, $stat, $matches)) {
throw new \Exception("Unrecognised output from stat. Expecting something like '$patt', found: '$stat'");
}
$mtimeSeconds = strtotime("{$matches[1]} {$matches[3]}");
$mtimeMillis = $matches[2];
return "$mtimeSeconds.$mtimeMillis";
}
}
मुझे यह विचार पसंद है, मैं 1 सेकंड के लिए सोने की तुलना में सामग्री में हेरफेर करना पसंद करता हूं, जो कि तेज़ तरीका है। पारितोषिक के लिए धन्यवाद। –