-2

So I'm trying to call strtotime function inside ajax looping but i dont knw hw to call it ive surf everywhere , n i cant find 1 thread about date(strtotime) in ajax .

heres my code, it return 01 Jan 1970 for every record loop

'<p> <?php echo date("d M Y",strtotime('+ data[i].date_event +')) ?> </p>' +

I guess php won't work inside ajax function, is it? any solution, my last solution is change it to php looping

pgSystemTester
  • 8,979
  • 2
  • 23
  • 49
  • 1
    Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Alon Eitan Dec 03 '18 at 06:02
  • 1
    `data[i].date_event` doesn't look like a php variable to me. If this is an ajax request, where's the ajax request here? – Alon Eitan Dec 03 '18 at 06:03
  • the main question isnt "what differ ajax n php ?" its "how to call php date strtotime inside ajax looping ?" – Anhar Panduwinata Dec 03 '18 at 06:05
  • I didn't ask _what differ ajax n php_, I asked where's the ajax part of this code – Alon Eitan Dec 03 '18 at 06:07

1 Answers1

1

You can use moment min js to convert date formate

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
    <script>

var date = data[i].date_event;
var newDate = moment(date).format('DD-MM-YYYY');


</script>
BInjal Patel
  • 321
  • 3
  • 16