1
I’m trying to capture the file date via javascript and send it to PHP.
Motive?
I want the date of the last file change.
$('#last_modified').val(arquivo[0].lastModified);
Variable file is:
<input type="file" name="teste" onchange="pegaArquivo(this.files)">
Which returns me "1423493594000" for the date: Mon Feb 09 2015 12:53:14 GMT-0200 (BRST)
However, when PHP reads this date it always returns the same: 12/31/1969
In php I do:
echo date ("d/m/Y", filectime($_POST['last_modified']));
Could you help me?
Javascript works in milliseconds and PHP in seconds, 1423493594000 in javascript gives Feb 2015, in php gives there to 2028 if not divided by
1000
... how you’re getting into PHP?– Sergio
Just like @Sergio said. This topic is a bit like your question, take a look and see if it helps you: http://stackoverflow.com/questions/10837022/convert-php-date-into-javascript-date-format
– Randrade
Excuse me, I updated the post: echo date ("d/m/Y", filectime($_POST['last_modified']));
– Raul3k
Raul, take a look at: http://www.html5rocks.com/en/tutorials/file/dndfiles/ right at the start he applies exactly what you would like. Show modification date. In this sector Using form input for Selecting. Take a test, upload and see the result :)
– Rafael Withoeft
Thanks @Sergio, that’s right, split by 1000.
– Raul3k
Thanks @Renilsonandrade, helped a lot too. =)
– Raul3k
@Rafaelwithoeft I will read the link calmly, maybe it helps even more =) By the way, how to pronounce your last name?
– Raul3k
@Raul3k " Viper "; I believe to be of German origin... kkkkk
– Rafael Withoeft
@Raul3k I haven’t seen in your code where the bug was, you didn’t put it where it came from
arquivo[0].lastModified
. But if you found the solution you can delete the question or ask an answer.– Sergio
@Rafaelwithoeft I imagine you spelling by phone rs I just posted the solution along with the code =)
– Raul3k
Obs: onchange="pegaArquivo(this.files)" Look at the onchange, this is where I’m getting it =)
– Raul3k
@Raul3k Yes, it’s always a difficulty, I don’t even try to talk anymore, I start spelling. kkkkk
– Rafael Withoeft