Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

Recommended Posts

This code aimed at printing a unix timestamp of todays date:

 

$toddate= date(mktime());

echo $toddate;

 

Produces this:

 

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead.

 

I want it to print out the current date.

Link to comment
https://forums.phpfreaks.com/topic/168392-time-problems/
Share on other sites

Not seen that one before, but according to the manual:

 

 

Errors/Exceptions

 

Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or the TZ environment variable. See also date_default_timezone_set()

 

So i'm assuming there's no timezone set in your PHP setup.

 

By the by, you don't need both of those functions to do what you want. You either want mk_time() with no parameters, date("U") or time().

Link to comment
https://forums.phpfreaks.com/topic/168392-time-problems/#findComment-888263
Share on other sites

I am working from a book, but the timezone is not mentioned anywhere.  So I don't understand how it works, or how you set it.

 

I am working on creating a webpage that shows how long somebody has had an account for.  Their user rating is based on how long they have been signed up.  So I need to put the current timestamp into a variable and then subtract the date when they created their account.

Link to comment
https://forums.phpfreaks.com/topic/168392-time-problems/#findComment-888353
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.