Home  >  Q&A  >  body text

PHP method to get local time

Why can't procedural code get the same results as object-oriented code? I have legacy code that requires program results. Please note that I have a workaround but I would like to understand why the program code is not getting the local time.

`$dt = new DateTime("now", new DateTimeZone('America/Los_Angeles'));
 $now = strtotime($dt->format('m/d/Y, H:i:s')); //This is a work-around which works
 $oo = date('Y-m-d H:i:s',$now);
 //Procedural Code
 $now = date_timestamp_get($dt);
 $pc = date('Y.m.d H:i:s',$now);        `

P粉396248578P粉396248578373 days ago460

reply all(1)I'll reply

  • P粉384366923

    P粉3843669232023-09-16 00:36:14

    Answer in comments, courtesyAdyson

    reply
    0
  • Cancelreply