mardi 16 juillet 2019

Display Timezone as UTC-5 (CDT) - America/Chicago in Select input using Laravel

I am populating a timezone select by getting a list of timezones in my controller like this:

use DateTimeZone;

...


public function show() {
    $timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);

    dd($timezones); // 87 => "America/Chicago"

    return view('view.show', compact(['timezones',]));
}

This works well to get a list of timezone(s) and save that value to the db as "America/Chicago".

On my view, I am also showing "America/Chicago", however, I'd like the name of the input to read something like this:

UTC-5 (CDT) - America/Chicago

I'm not sure how to get "UTC-5 (CDT) -" from my timezones array that I am passing to the view.

Thank you for any suggestions!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire