Jump to content

Archived

This topic is now archived and is closed to further replies.

almightyegg

re-order date()

Recommended Posts

i have $time = date(Y-d-m H:i:s); and it works fine, but i want it to be day-month-year and in GMT time  ???

Share this post


Link to post
Share on other sites
You can try using the [url=http://www.php.net/gmdate]gmdate()[/url] function.

Ken

Share this post


Link to post
Share on other sites
thanks that now shows in right order but currently uk is in GMT + 1 hour...how would i put that into:
[code=php:0]
$time = gmdate("d-m-Y H:i:s");
[/code]

Share this post


Link to post
Share on other sites
[code]
<?php

$time = date("d-m-Y H:i:s",strtotime('now + 1 hours'));

?>
[/code]

Share this post


Link to post
Share on other sites
oooh wait...i went to update my database with 00-00-0000 00:00:00 rather than 0000-00-00 00:00:00 and it wouldnt let me change it...so the new time doesnt go in, leaving it at 0000-00-00 00:00:00 in the database...how do i change it??

Share this post


Link to post
Share on other sites
Your mysql field type is probably set as "DATETIME" then, you can e.g. change it to VARCHAR or something,
more info found here:
http://help.scibit.com/Mascon/masconMySQL_Field_Types.html

Share this post


Link to post
Share on other sites
Leave how it's stored in the DB alone. Just display it differently.

Ken

Share this post


Link to post
Share on other sites
If you have a lot of existing different scripts (pages) that you display the date in, my way is the easiest one - but, i still agree with kenrbnsn that you for future purposes might want to store all dates in datetime format and modify it when you want to use it.

Share this post


Link to post
Share on other sites

×

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.