0

I can't see my location time with following php function:

echo date("y-m-d h:m:s A");

it's show 12-05-05 08:05:12 AM BUT it's 12-05-05 12:40:12 PM NOW

Can anyoe fix this issue..
Thanks.

0

5 Answers 5

1

Set your preferred timezone in php.ini:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Manila

You can see the list of supported timezones here.

Or you can go other way, use date_default_timezone_set().

Sign up to request clarification or add additional context in comments.

1 Comment

@Shibbir : Remember to accept the answers that fixes your problem
1

Set setlocale function. Here this the description

Comments

0

Fix your server time, or use this:

http://php.net/manual/en/function.date-default-timezone-set.php

Comments

0

You are using m, but it's used to represent month, not minutes.

This is probably what you'd like to do:

echo date("y-m-d h:i:s A");

After that, you're either using the wrong timezone or the servers time is badly setup. If you have access to the server run date in a terminal.

2 Comments

I'm checking it in my localhost but it's still show wrong time.. 4 hours different from my local time.
Set the default timezone date_default_timezone_set so that it ticks with your own.
0

Apart from Blake comment, i suggets try fixing your time zone, add +/- time you require time , example

$timediff = 10;

$diff= $timediff+ ($timediff* 60 * 60)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.