Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Convert Date (String) to new Date Format

Featured Replies

Good Morning,

 

I've outputted some data from a MSSQL database, the data within the database reads '01/07/2013 11:11:16' and when I access this via a PHP script and echo it ... It displays as 'Jul 01 2013 11:11:16PM'.

 

I need the format to be in : '2013-07-11 11:11:16'.

 

Please can someone help me write the code to make the str change to the format needed.

 

Kind Regards,

 

Shaun Swales

Http://www.twitter.co.uk/ShaunSwales

mysql has a date_format function which converts the date directly, I'm not sure if mssql has a similar function.

 

PHP has a bunch of date/time functions - you can look them up in the php manual. I think you'll need to convert the date to a unix timestamp and then convert it to your required format. Assuming $date is the date you've retrieved, you could do something like

$formatted = strftime('%Y-%m-%d %H:%M:%S', strtotime($date));

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.