Hello experts, I am new to php so have been struggling with a simple code of ftp_raw_list My code is:
<?php
$ftp_server = "xxxx";
$ftp_username="xxx";
$ftp_userpass="xxxx";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$mode = ftp_pasv($ftp_conn, TRUE);
$ftp_rawlist = ftp_rawlist($ftp_conn, ".");
ftp_close($ftp_conn);
var_dump($ftp_rawlist);
?>
Here I observe that last modified date of the files are NOT is same format. Here is a sample:
16 => string '-rw-r--r-- 1 807 801 7597 Apr 01 2019 year_available.pdf' (length=74)
19 => string '-rw-r--r-- 1 807 801 8250 Sep 03 17:27 year_missing1.pdf' (length=75)
20 => string '-rw-r--r-- 1 807 801 24208 Jan 02 12:14 year_missing2.pdf' (length=75)
21 => string '-rw-r--r-- 1 807 801 6849 Feb 04 14:12 year_missing3.pdf' (length=75)
22 => string '-rw-r--r-- 1 807 801 6778 Jul 04 2019 year_again_showing1.pdf' (length=75)
23 => string '-rw-r--r-- 1 807 801 8668 Nov 01 09:17 year_missing4.pdf' (length=75)
24 => string '-rw-r--r-- 1 807 801 7065 Oct 04 11:46 year_missing5.pdf' (length=75)
My task is to show ftp file list in a tabular form with an option of dynamic sorting - file name wise, date wise, size wise etc. Rest I could do , but I am not able to sort the files in date column because of non-uniformity of date structure. Please guide me how do I format the dates in a uniform manner let us say yyyy-mm-dd hh24:mi so as to successfully sort on date field?