Perad Posted December 21, 2006 Share Posted December 21, 2006 I am using datestamp in my 'postdate' db field. When someone enters a post the postdate is stored. How do i format a variable with the date function? I can't work out where the variable goes.This is what i have...[code]$postdate = strtotime($row['postdate']);$postdate = date("j F, Y, g:i a"); [/code]Help on this is very much appreciated. EDIT: I am trying to get to display -- Day Month Year : Time Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/ Share on other sites More sharing options...
obsidian Posted December 21, 2006 Share Posted December 21, 2006 To get "d Mon Year, Time" you need to use the following format:[code]<?php$postdate = strtotime($row['postdate']);echo date('j F Y, g:i a', $postdate);?>[/code]Is that what you're after? Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/#findComment-146038 Share on other sites More sharing options...
drifter Posted December 21, 2006 Share Posted December 21, 2006 do not forget to check how users enter dates - you may also find mktime() usefull Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/#findComment-146039 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 [quote author=drifter link=topic=119563.msg489800#msg489800 date=1166728445]do not forget to check how users enter dates - you may also find mktime() usefull[/quote]It's coming from the database in this instance, so should be fine, but good point.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/#findComment-146044 Share on other sites More sharing options...
Perad Posted December 21, 2006 Author Share Posted December 21, 2006 Ah thats perfect thanks, i just couldn't work out where the variable $postdate fitted in the date function. Cheers for the help guys Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/#findComment-146045 Share on other sites More sharing options...
drifter Posted December 21, 2006 Share Posted December 21, 2006 [quote]It's coming from the database in this instance, so should be fine, but good point.[/quote]I saw $postdate and I though $_POST['date']... oops Link to comment https://forums.phpfreaks.com/topic/31527-solved-format-the-date/#findComment-146065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.